ReactOS  0.4.12-dev-418-g3df31a8
capicon.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 #include "windows.h"
20 #include "stdio.h"
21 #include "resource.h"
22 
23 WCHAR WndClass[] = L"capicon_class";
24 
27 
28 
30  UINT msg,
31  WPARAM wParam,
32  LPARAM lParam)
33 {
34  HICON hIcon;
35 
36  switch (msg)
37  {
38  case WM_GETICON:
39  if(testnum>2)
40  {
41  if(wParam == ICON_SMALL)
43  else if(wParam == ICON_BIG)
45  else hIcon = (HICON)1;
46 
47  if(!hIcon)
48  {
49  printf("LoadIcon() failed: %d\n", (INT)GetLastError());
50  break;
51  }
52 
53  return (LRESULT)hIcon;
54  }
55  break;
56 
57  case WM_DESTROY:
58  PostQuitMessage(0);
59  return 0;
60  }
61 
62  return DefWindowProc(hWnd, msg, wParam, lParam);
63 }
64 
65 
66 int wmain(int argc, wchar_t**argv)
67 {
68  HWND hWnd;
69  MSG msg;
70  WNDCLASSEX wcx;
71  UINT result;
72 
73  if(argc<2)
74  {
75  printf("DrawCaption icon test.\n");
76  printf("USAGE: drawcap.exe <testnumber>\n\n");
77  printf("Available tests:\n"
78  "1. Class small icon\n"
79  "2. Class big icon\n"
80  "3. Class small icon + WM_GETICON\n"
81  "4. Class big icon + WM_GETICON\n"
82  "5. WM_GETICON only\n\n");
83  return 0;
84  }
85 
86  testnum = _wtoi(argv[1]);
87  if(testnum < 1 || testnum > 5)
88  {
89  printf("Unknown test %d\n", testnum);
90  return 1;
91  }
92 
94 
95  memset(&wcx, 0, sizeof(wcx));
96  wcx.cbSize = sizeof(wcx);
97  wcx.style = CS_HREDRAW | CS_VREDRAW;
98  wcx.lpfnWndProc = (WNDPROC) WndProc;
99  wcx.hInstance = hInst;
100  wcx.hbrBackground = (HBRUSH)COLOR_WINDOW;
101  wcx.lpszClassName = WndClass;
103  if(testnum == 1 || testnum == 3)
105 
106  if(!(result = RegisterClassEx(&wcx)))
107  {
108  printf("Shit! RegisterClassEx failed: %d\n",
109  (int)GetLastError());
110  return 1;
111  }
112 
113  hWnd = CreateWindowEx(0,
114  WndClass,
115  L"DrawCaption icon test",
119  250,
120  100,
121  NULL,
122  0,
123  hInst,
124  NULL);
125 
126  if(!hWnd)
127  {
128  printf("Shit! Can't create wnd!\n");
130  return 1;
131  }
132 
133 
136 
137  while(GetMessage(&msg, NULL, 0, 0 ))
138  {
141  }
142 
144  return 0;
145 }
#define WS_THICKFRAME
Definition: pedump.c:630
UINT style
Definition: winuser.h:3155
static int argc
Definition: ServiceArgs.c:12
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define DispatchMessage
Definition: winuser.h:5631
BOOL WINAPI TranslateMessage(_In_ const MSG *)
static HICON
Definition: imagelist.c:84
#define RegisterClassEx
Definition: winuser.h:5703
WNDPROC lpfnWndProc
Definition: winuser.h:3156
LPCSTR lpszClassName
Definition: winuser.h:3164
__wchar_t WCHAR
Definition: xmlstorage.h:180
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
HINSTANCE hInst
Definition: capicon.c:25
#define CALLBACK
Definition: compat.h:27
BOOL WINAPI UpdateWindow(_In_ HWND)
HWND hWnd
Definition: settings.c:17
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define CS_HREDRAW
Definition: winuser.h:648
HICON hIconSm
Definition: winuser.h:3165
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define argv
Definition: mplay32.c:18
#define COLOR_WINDOW
Definition: winuser.h:908
int32_t INT
Definition: typedefs.h:56
WPARAM wParam
Definition: combotst.c:138
UINT_PTR WPARAM
Definition: windef.h:207
int wmain(int argc, wchar_t **argv)
Definition: capicon.c:66
#define ICON_SMALL
Definition: tnclass.cpp:48
HINSTANCE hInstance
Definition: winuser.h:3159
LONG_PTR LPARAM
Definition: windef.h:208
#define CreateWindowEx
Definition: winuser.h:5621
#define CW_USEDEFAULT
Definition: winuser.h:225
UINT msg
Definition: msvc.h:92
#define ID_ICON1BIG
Definition: resource.h:4
smooth NULL
Definition: ftsmooth.c:416
UINT cbSize
Definition: winuser.h:3154
#define SW_SHOW
Definition: winuser.h:769
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: capicon.c:29
HBRUSH hbrBackground
Definition: winuser.h:3162
#define DefWindowProc
Definition: ros2win.h:31
#define WM_DESTROY
Definition: winuser.h:1591
#define CS_VREDRAW
Definition: winuser.h:653
#define WS_OVERLAPPED
Definition: pedump.c:615
#define ID_ICON1SM
Definition: resource.h:5
#define ID_ICON2BIG
Definition: resource.h:6
unsigned int UINT
Definition: ndis.h:50
#define ID_ICON2SM
Definition: resource.h:7
HICON hIcon
Definition: winuser.h:3160
static const WCHAR L[]
Definition: oid.c:1087
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2859
#define GetModuleHandle
Definition: winbase.h:3641
HICON hIcon
Definition: msconfig.c:44
#define GetMessage
Definition: winuser.h:5656
#define msg(x)
Definition: auth_time.c:54
#define LoadIcon
Definition: winuser.h:5679
LONG_PTR LRESULT
Definition: windef.h:209
#define UnregisterClass
Definition: winuser.h:5727
#define WS_SYSMENU
Definition: pedump.c:629
GLuint64EXT * result
Definition: glext.h:11304
#define memset(x, y, z)
Definition: compat.h:39
LPARAM lParam
Definition: combotst.c:139
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
INT testnum
Definition: capicon.c:26
WCHAR WndClass[]
Definition: capicon.c:23
#define ICON_BIG
Definition: tnclass.cpp:51
#define printf
Definition: config.h:203