ReactOS 0.4.15-dev-7842-g558ab78
sysicon.c
Go to the documentation of this file.
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
27WCHAR WndClass[] = L"sysicon_class";
29
31 UINT msg,
34{
35 switch (msg)
36 {
37 case WM_PAINT:
38 {
39 HDC hDc;
40 PAINTSTRUCT Ps;
41 RECT Rect;
43
44 Rect.left = 10;
45 Rect.top = 10;
46 Rect.right -= 10;
47 Rect.bottom = 25;
48
49 hDc = BeginPaint(hWnd, &Ps);
51
52 DrawCaption(hWnd, hDc, &Rect, DC_GRADIENT | DC_ACTIVE | DC_TEXT | DC_ICON);
53
54 EndPaint(hWnd, &Ps);
55
56 return 0;
57 }
58
59 case WM_DESTROY:
61 return 0;
62 }
63
65}
66
68 HINSTANCE hPrevInstance,
69 LPWSTR lpCmdLine,
70 int nCmdShow)
71{
72 HWND hWnd1a, hWnd1b, hWnd2a, hWnd2b, hWnd3a, hWnd3b;
73 MSG msg;
74 WNDCLASSEXW wcx;
76
77 memset(&wcx, 0, sizeof(wcx));
78 wcx.cbSize = sizeof(wcx);
80 wcx.hInstance = hInst;
81 wcx.hbrBackground = (HBRUSH)COLOR_WINDOW;
83
84 if (!(result = RegisterClassExW(&wcx)))
85 return 1;
86
87 /* Load the user icons */
90
91 /* WS_EX_DLGMODALFRAME */
94 L"WS_SYSMENU | WS_EX_DLGMODALFRAME without user icon",
97 400, 100,
98 NULL, 0,
99 hInst, NULL);
100 if (!hWnd1a)
101 return 1;
102
103 ShowWindow(hWnd1a, SW_SHOW);
104 UpdateWindow(hWnd1a);
105
106 /* WS_EX_DLGMODALFRAME */
108 WndClass,
109 L"WS_SYSMENU | WS_EX_DLGMODALFRAME with user icon",
112 400, 100,
113 NULL, 0,
114 hInst, NULL);
115
116 if (!hWnd1b)
117 return 1;
118
119 ShowWindow(hWnd1b, SW_SHOW);
120 UpdateWindow(hWnd1b);
121 SendMessageW(hWnd1b, WM_SETICON, ICON_SMALL, (LPARAM)hIconSm);
122 SendMessageW(hWnd1b, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
123
125 WndClass,
126 L"WS_SYSMENU | WS_EX_TOOLWINDOW without user icon",
129 400, 100,
130 NULL, 0,
131 hInst, NULL);
132 if (!hWnd2a)
133 return 1;
134
135 ShowWindow(hWnd2a, SW_SHOW);
136 UpdateWindow(hWnd2a);
137
139 WndClass,
140 L"WS_SYSMENU | WS_EX_TOOLWINDOW with user icon",
143 400, 100,
144 NULL, 0,
145 hInst, NULL);
146 if (!hWnd2b)
147 return 1;
148
149 ShowWindow(hWnd2b, SW_SHOW);
150 UpdateWindow(hWnd2b);
151 SendMessageW(hWnd2b, WM_SETICON, ICON_SMALL, (LPARAM)hIconSm);
152 SendMessageW(hWnd2b, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
153
154 hWnd3a = CreateWindowExW(0,
155 WndClass,
156 L"WS_SYSMENU without user icon",
159 400, 100,
160 NULL, 0,
161 hInst, NULL);
162 if (!hWnd3a)
163 return 1;
164
165 ShowWindow(hWnd3a, SW_SHOW);
166 UpdateWindow(hWnd3a);
167
168 hWnd3b = CreateWindowExW(0,
169 WndClass,
170 L"WS_SYSMENU with user icon",
173 400, 100,
174 NULL, 0,
175 hInst, NULL);
176 if (!hWnd3b)
177 return 1;
178
179 ShowWindow(hWnd3b, SW_SHOW);
180 UpdateWindow(hWnd3b);
181 SendMessageW(hWnd3b, WM_SETICON, ICON_SMALL, (LPARAM)hIconSm);
182 SendMessageW(hWnd3b, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
183
184 while(GetMessageW(&msg, NULL, 0, 0 ))
185 {
188 }
189
190 if (hIcon) DestroyIcon(hIcon);
192
194 return 0;
195}
#define msg(x)
Definition: auth_time.c:54
HWND hWnd
Definition: settings.c:17
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define DC_ACTIVE
Definition: dc21x4.h:120
#define NULL
Definition: types.h:112
#define APIENTRY
Definition: api.h:79
#define CALLBACK
Definition: compat.h:35
HINSTANCE hInst
Definition: dxdiag.c:13
GLuint64EXT * result
Definition: glext.h:11304
static HDC
Definition: imagelist.c:92
static HICON
Definition: imagelist.c:84
unsigned int UINT
Definition: ndis.h:50
#define L(x)
Definition: ntvdm.h:50
#define WS_CAPTION
Definition: pedump.c:624
#define WS_EX_DLGMODALFRAME
Definition: pedump.c:645
#define WS_SYSMENU
Definition: pedump.c:629
#define memset(x, y, z)
Definition: compat.h:39
LPCWSTR lpszClassName
Definition: winuser.h:3226
HBRUSH hbrBackground
Definition: winuser.h:3224
WNDPROC lpfnWndProc
Definition: winuser.h:3218
UINT cbSize
Definition: winuser.h:3216
HINSTANCE hInstance
Definition: winuser.h:3221
int APIENTRY wWinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
Definition: sysicon.c:67
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: sysicon.c:30
HICON hIcon
Definition: sysicon.c:28
WCHAR WndClass[]
Definition: sysicon.c:27
HICON hIconSm
Definition: sysicon.c:28
#define ICON_BIG
Definition: tnclass.cpp:51
#define ICON_SMALL
Definition: tnclass.cpp:48
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
#define TRANSPARENT
Definition: wingdi.h:950
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
#define WM_PAINT
Definition: winuser.h:1620
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define COLOR_WINDOW
Definition: winuser.h:918
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI DrawCaption(_In_ HWND, _In_ HDC, _In_ LPCRECT, _In_ UINT)
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
#define IMAGE_ICON
Definition: winuser.h:212
#define LR_COPYFROMRESOURCE
Definition: winuser.h:1099
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE hInst, _In_ LPCWSTR name, _In_ UINT type, _In_ int cx, _In_ int cy, _In_ UINT fuLoad)
Definition: cursoricon.c:2203
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
#define SM_CYSMICON
Definition: winuser.h:1013
HANDLE WINAPI CopyImage(_In_ HANDLE, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:1987
#define SM_CXSMICON
Definition: winuser.h:1012
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
BOOL WINAPI UpdateWindow(_In_ HWND)
ATOM WINAPI RegisterClassExW(_In_ CONST WNDCLASSEXW *)
#define DC_TEXT
Definition: winuser.h:430
#define LR_SHARED
Definition: winuser.h:1100
#define CW_USEDEFAULT
Definition: winuser.h:225
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
#define SW_SHOW
Definition: winuser.h:775
#define WM_DESTROY
Definition: winuser.h:1609
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)
#define DC_ICON
Definition: winuser.h:429
#define LR_DEFAULTSIZE
Definition: winuser.h:1094
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2906
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
int WINAPI GetSystemMetrics(_In_ int)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2053
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184