ReactOS  0.4.14-dev-554-g2f8d847
capicon.c File Reference
#include "windows.h"
#include "stdio.h"
#include "resource.h"
Include dependency graph for capicon.c:

Go to the source code of this file.

Functions

LRESULT CALLBACK WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
int wmain (int argc, wchar_t **argv)
 

Variables

WCHAR WndClass [] = L"capicon_class"
 
HINSTANCE hInst
 
INT testnum = 0
 

Function Documentation

◆ wmain()

int wmain ( int  argc,
wchar_t **  argv 
)

Definition at line 66 of file capicon.c.

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:3177
static int argc
Definition: ServiceArgs.c:12
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define DispatchMessage
Definition: winuser.h:5740
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define RegisterClassEx
Definition: winuser.h:5812
WNDPROC lpfnWndProc
Definition: winuser.h:3178
LPCSTR lpszClassName
Definition: winuser.h:3186
_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
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:3187
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define argv
Definition: mplay32.c:18
#define COLOR_WINDOW
Definition: winuser.h:908
HINSTANCE hInstance
Definition: winuser.h:3181
#define CreateWindowEx
Definition: winuser.h:5730
#define CW_USEDEFAULT
Definition: winuser.h:225
#define ID_ICON1BIG
Definition: resource.h:4
smooth NULL
Definition: ftsmooth.c:416
UINT cbSize
Definition: winuser.h:3176
#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:3184
#define CS_VREDRAW
Definition: winuser.h:653
#define WS_OVERLAPPED
Definition: pedump.c:615
#define ID_ICON1SM
Definition: resource.h:5
HICON hIcon
Definition: winuser.h:3182
static const WCHAR L[]
Definition: oid.c:1250
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2881
#define GetModuleHandle
Definition: winbase.h:3661
unsigned int UINT
Definition: ndis.h:50
#define GetMessage
Definition: winuser.h:5765
#define msg(x)
Definition: auth_time.c:54
#define LoadIcon
Definition: winuser.h:5788
#define UnregisterClass
Definition: winuser.h:5836
#define WS_SYSMENU
Definition: pedump.c:629
GLuint64EXT * result
Definition: glext.h:11304
#define memset(x, y, z)
Definition: compat.h:39
INT testnum
Definition: capicon.c:26
WCHAR WndClass[]
Definition: capicon.c:23
#define printf
Definition: config.h:203

◆ WndProc()

LRESULT CALLBACK WndProc ( HWND  hWnd,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 29 of file capicon.c.

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 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
static HICON
Definition: imagelist.c:84
HINSTANCE hInst
Definition: capicon.c:25
HWND hWnd
Definition: settings.c:17
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
int32_t INT
Definition: typedefs.h:56
WPARAM wParam
Definition: combotst.c:138
#define ICON_SMALL
Definition: tnclass.cpp:48
#define DefWindowProc
Definition: ros2win.h:31
#define WM_DESTROY
Definition: winuser.h:1591
#define ID_ICON2BIG
Definition: resource.h:6
#define ID_ICON2SM
Definition: resource.h:7
HICON hIcon
Definition: msconfig.c:44
#define msg(x)
Definition: auth_time.c:54
#define LoadIcon
Definition: winuser.h:5788
LONG_PTR LRESULT
Definition: windef.h:209
LPARAM lParam
Definition: combotst.c:139
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
INT testnum
Definition: capicon.c:26
#define ICON_BIG
Definition: tnclass.cpp:51
#define printf
Definition: config.h:203

Referenced by wmain().

Variable Documentation

◆ hInst

HINSTANCE hInst

Definition at line 25 of file capicon.c.

Referenced by wmain(), and WndProc().

◆ testnum

INT testnum = 0

Definition at line 26 of file capicon.c.

Referenced by wmain(), and WndProc().

◆ WndClass