Partial merge of condrv_restructure branch r65657.
[reactos.git] / rostests / win32 / user32 / sysicon / sysicon.c
1 /*
2 * Copyright 2006 Saveliy Tretiakov
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18
19 /* This testapp demonstrates WS_SYSMENU + WS_EX_DLGMODALFRAME
20 * behavior and shows that DrawCaption does care
21 * about WS_EX_DLGMODALFRAME and WS_EX_TOOLWINDOW
22 */
23
24 #include "windows.h"
25 #include "stdio.h"
26 #include "resource.h"
27
28 WCHAR WndClass[] = L"sysicon_class";
29
30 LRESULT CALLBACK WndProc(HWND hWnd,
31 UINT msg,
32 WPARAM wParam,
33 LPARAM lParam)
34 {
35
36 switch (msg)
37 {
38
39 case WM_PAINT:
40 {
41 HDC hDc;
42 PAINTSTRUCT Ps;
43 RECT Rect;
44 GetClientRect(hWnd, &Rect);
45
46 Rect.left = 10;
47 Rect.top = 10;
48 Rect.right-=10;
49 Rect.bottom = 25;
50
51 hDc = BeginPaint(hWnd, &Ps);
52 SetBkMode( hDc, TRANSPARENT );
53
54 DrawCaption(hWnd, hDc, &Rect, DC_GRADIENT | DC_ACTIVE | DC_TEXT | DC_ICON);
55
56 EndPaint(hWnd, &Ps);
57
58 return 0;
59 }
60
61 case WM_DESTROY:
62 PostQuitMessage(0);
63 return 0;
64 }
65
66 return DefWindowProc(hWnd, msg, wParam, lParam);
67 }
68
69 int APIENTRY wWinMain(HINSTANCE hInst,
70 HINSTANCE hPrevInstance,
71 LPWSTR lpCmdLine,
72 int nCmdShow)
73 {
74 HWND hWnd1, hWnd2, hWnd3;
75 MSG msg;
76 WNDCLASSEX wcx;
77 UINT result;
78
79 memset(&wcx, 0, sizeof(wcx));
80 wcx.cbSize = sizeof(wcx);
81 wcx.lpfnWndProc = (WNDPROC) WndProc;
82 wcx.hInstance = hInst;
83 wcx.hbrBackground = (HBRUSH)COLOR_WINDOW;
84 wcx.lpszClassName = WndClass;
85
86 if(!(result = RegisterClassEx(&wcx)))
87 {
88 return 1;
89 }
90
91 /* WS_EX_DLGMODALFRAME */
92 hWnd1 = CreateWindowEx(WS_EX_DLGMODALFRAME,
93 WndClass,
94 L"WS_SYSMENU | WS_EX_DLGMODALFRAME",
95 WS_CAPTION | WS_SYSMENU ,
96 CW_USEDEFAULT,
97 CW_USEDEFAULT,
98 400,
99 100,
100 NULL,
101 0,
102 hInst,
103 NULL);
104
105 if(!hWnd1)
106 {
107 return 1;
108 }
109
110 ShowWindow(hWnd1, SW_SHOW);
111 UpdateWindow(hWnd1);
112
113 hWnd2 = CreateWindowEx(WS_EX_TOOLWINDOW,
114 WndClass,
115 L"WS_SYSMENU | WS_EX_TOOLWINDOW",
116 WS_CAPTION | WS_SYSMENU ,
117 CW_USEDEFAULT,
118 CW_USEDEFAULT,
119 400,
120 100,
121 NULL,
122 0,
123 hInst,
124 NULL);
125
126 if(!hWnd2)
127 {
128 return 1;
129 }
130
131 ShowWindow(hWnd2, SW_SHOW);
132 UpdateWindow(hWnd2);
133
134 hWnd3 = CreateWindowEx(0,
135 WndClass,
136 L"WS_SYSMENU ",
137 WS_CAPTION | WS_SYSMENU ,
138 CW_USEDEFAULT,
139 CW_USEDEFAULT,
140 400,
141 100,
142 NULL,
143 0,
144 hInst,
145 NULL);
146
147 if(!hWnd3)
148 {
149 return 1;
150 }
151
152 ShowWindow(hWnd3, SW_SHOW);
153 UpdateWindow(hWnd3);
154
155 while(GetMessage(&msg, NULL, 0, 0 ))
156 {
157 TranslateMessage(&msg);
158 DispatchMessage(&msg);
159 }
160
161 UnregisterClass(WndClass, hInst);
162 return 0;
163 }