2 * Desktop window class.
4 * Copyright 1994 Alexandre Julliard
7 static char Copyright
[] = "Copyright Alexandre Julliard, 1994";
15 /***********************************************************************
16 * DESKTOP_DoEraseBkgnd
18 * Handle the WM_ERASEBKGND message.
20 static LONG
DESKTOP_DoEraseBkgnd( HWND hwnd
, HDC hdc
, DESKTOPINFO
*infoPtr
)
24 /* Set colors in case pattern is a monochrome bitmap */
25 SetBkColor( hdc
, RGB(0,0,0) );
26 SetTextColor( hdc
, GetSysColor(COLOR_BACKGROUND
) );
27 GetClientRect( hwnd
, &rect
);
28 FillRect( hdc
, &rect
, infoPtr
->hbrushPattern
);
33 /***********************************************************************
36 * Window procedure for the desktop window.
38 LONG
DesktopWndProc ( HWND hwnd
, WORD message
, WORD wParam
, LONG lParam
)
40 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
41 DESKTOPINFO
*infoPtr
= (DESKTOPINFO
*)wndPtr
->wExtra
;
43 /* Most messages are ignored (we DON'T call DefWindowProc) */
47 /* Warning: this message is sent directly by */
48 /* WIN_CreateDesktopWindow() and does not contain a valid lParam */
50 infoPtr
->hbrushPattern
= 0;
51 infoPtr
->hbitmapWallPaper
= 0;
56 if (rootWindow
== DefaultRootWindow(display
)) return 1;
57 return DESKTOP_DoEraseBkgnd( hwnd
, (HDC
)wParam
, infoPtr
);
64 /***********************************************************************
65 * SetDeskPattern (USER.279)
70 GetProfileString( "desktop", "Pattern", "(None)", buffer
, 100 );
71 return DESKTOP_SetPattern( buffer
);
75 /***********************************************************************
76 * SetDeskWallPaper (USER.285)
78 BOOL
SetDeskWallPaper( LPSTR filename
)
84 /***********************************************************************
87 * Set the desktop pattern.
89 BOOL
DESKTOP_SetPattern(char *pattern
)
91 WND
*wndPtr
= WIN_FindWndPtr( GetDesktopWindow() );
92 DESKTOPINFO
*infoPtr
= (DESKTOPINFO
*)wndPtr
->wExtra
;
95 if (infoPtr
->hbrushPattern
) DeleteObject( infoPtr
->hbrushPattern
);
96 memset( pat
, 0, sizeof(pat
) );
97 if (pattern
&& sscanf( pattern
, " %d %d %d %d %d %d %d %d",
98 &pat
[0], &pat
[1], &pat
[2], &pat
[3],
99 &pat
[4], &pat
[5], &pat
[6], &pat
[7] ))
105 for (i
= 0; i
< 8; i
++) pattern
[i
] = pat
[i
] & 0xffff;
106 hbitmap
= CreateBitmap( 8, 8, 1, 1, pattern
);
107 infoPtr
->hbrushPattern
= CreatePatternBrush( hbitmap
);
108 DeleteObject( hbitmap
);
110 else infoPtr
->hbrushPattern
= CreateSolidBrush( GetSysColor(COLOR_BACKGROUND
) );