This example uses WinQueryDesktopBkgnd to query the current desktop background bit map before setting it to a new bit map with WinSetDesktopBkgnd.

#define INCL_WINDESKTOP
#define INCL_WINWINDOWMGR
#include <OS2.H>
HAB hab;
HWND    hwndDeskTop;
DESKTOP DeskTopState;
HBITMAP  hbm;
HBITMAP hbm_user;


WinQueryDesktopBkgnd(HWND_DESKTOP,
                     &DeskTopState);

if (hbm_user != DeskTopState.hbm)
{

 DeskTopState.fl = SDT_LOADFILE;
               /* the szFile is used to load the bit map because */
               /* the fl parameter is set to SDT_LOADFILE.      */
 strcpy(DeskTopState.szFile,"fruit.bmp");
 DeskTopState.hbm = hbm_user;
 WinSetDesktopBkgnd(hwndDeskTop,
                    &DeskTopState);
}


[Back] [Next]