Release 940405
[wine/gsoc-2012-control.git] / controls / desktop.c
blob183b2a2597a95c0972e268f04b54955af2f6d533
1 /*
2 * Desktop window class.
4 * Copyright 1994 Alexandre Julliard
5 */
7 static char Copyright[] = "Copyright Alexandre Julliard, 1994";
9 #include <stdio.h>
10 #include <string.h>
11 #include "win.h"
12 #include "desktop.h"
15 /***********************************************************************
16 * DESKTOP_DoEraseBkgnd
18 * Handle the WM_ERASEBKGND message.
20 static LONG DESKTOP_DoEraseBkgnd( HWND hwnd, HDC hdc, DESKTOPINFO *infoPtr )
22 RECT rect;
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 );
29 return 1;
33 /***********************************************************************
34 * DesktopWndProc
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) */
45 switch(message)
47 /* Warning: this message is sent directly by */
48 /* WIN_CreateDesktopWindow() and does not contain a valid lParam */
49 case WM_NCCREATE:
50 infoPtr->hbrushPattern = 0;
51 infoPtr->hbitmapWallPaper = 0;
52 SetDeskPattern();
53 break;
55 case WM_ERASEBKGND:
56 if (rootWindow == DefaultRootWindow(display)) return 1;
57 return DESKTOP_DoEraseBkgnd( hwnd, (HDC)wParam, infoPtr );
60 return 0;
64 /***********************************************************************
65 * SetDeskPattern (USER.279)
67 BOOL SetDeskPattern()
69 char buffer[100];
70 GetProfileString( "desktop", "Pattern", "(None)", buffer, 100 );
71 return DESKTOP_SetPattern( buffer );
75 /***********************************************************************
76 * SetDeskWallPaper (USER.285)
78 BOOL SetDeskWallPaper( LPSTR filename )
80 return TRUE;
84 /***********************************************************************
85 * DESKTOP_SetPattern
87 * Set the desktop pattern.
89 BOOL DESKTOP_SetPattern(char *pattern )
91 WND *wndPtr = WIN_FindWndPtr( GetDesktopWindow() );
92 DESKTOPINFO *infoPtr = (DESKTOPINFO *)wndPtr->wExtra;
93 int pat[8];
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] ))
101 WORD pattern[8];
102 HBITMAP hbitmap;
103 int i;
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) );
111 return TRUE;