ReactOS 0.4.15-dev-7842-g558ab78
drawcap.c File Reference
#include "windows.h"
#include "resource.h"
#include "stdio.h"
Include dependency graph for drawcap.c:

Go to the source code of this file.

Functions

VOID CapTest (HWND hWnd, HDC hDc, LPRECT pR, WCHAR *Text, DWORD Flags, WCHAR *AddonStr, DWORD Addon)
 
VOID DrawCaptionTest (HWND hWnd, HDC hDc, WCHAR *AddonStr, DWORD Addon)
 
LRESULT CALLBACK CaptWndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
int wmain (int argc, wchar_t **argv)
 

Variables

WCHAR CaptWndClass [] = L"captwnd_class"
 
HINSTANCE hInst
 
INT testnum = 0
 

Function Documentation

◆ CapTest()

VOID CapTest ( HWND  hWnd,
HDC  hDc,
LPRECT  pR,
WCHAR Text,
DWORD  Flags,
WCHAR AddonStr,
DWORD  Addon 
)

Definition at line 37 of file drawcap.c.

44{
45 WCHAR Buf[512];
46
47 lstrcpy(Buf, AddonStr);
48 if(lstrlen(Buf))lstrcat(Buf, L" | ");
49 lstrcat(Buf, Text);
50
51 DrawText( hDc, Buf, lstrlen(Buf), pR, DT_LEFT );
52
53 pR->top+=20;
54 pR->bottom+=20;
55
56 if(!DrawCaption(hWnd, hDc, pR, Flags | Addon))
57 {
58 printf("PAINT: DrawCaption failed: %d\n", (int)GetLastError());
59 }
60
61 pR->top+=30;
62 pR->bottom+=30;
63}
HWND hWnd
Definition: settings.c:17
char * Text
Definition: combotst.c:136
#define printf
Definition: freeldr.h:93
#define L(x)
Definition: ntvdm.h:50
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define lstrcpy
Definition: winbase.h:3809
#define lstrlen
Definition: winbase.h:3811
#define lstrcat
Definition: winbase.h:3806
BOOL WINAPI DrawCaption(_In_ HWND, _In_ HDC, _In_ LPCRECT, _In_ UINT)
#define DrawText
Definition: winuser.h:5771
#define DT_LEFT
Definition: winuser.h:534
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by DrawCaptionTest().

◆ CaptWndProc()

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

Definition at line 113 of file drawcap.c.

117{
118
119
120 switch (msg)
121 {
122
123 case WM_PAINT:
124 {
125 HDC hDc;
126 PAINTSTRUCT Ps;
127
128 hDc = BeginPaint(hWnd, &Ps);
129 SetBkMode( hDc, TRANSPARENT );
130
131 switch(testnum)
132 {
133 case 1:
134 DrawCaptionTest(hWnd, hDc, L"", 0);
135 break;
136 case 2:
137 DrawCaptionTest(hWnd, hDc, L"DC_GRADIENT", DC_GRADIENT);
138 break;
139 case 3:
140 DrawCaptionTest(hWnd, hDc, L"DC_SMALLCAP", DC_SMALLCAP);
141 break;
142 case 4:
143 DrawCaptionTest(hWnd, hDc, L"DC_BUTTONS", DC_BUTTONS);
144 break;
145 case 5:
147 L"DC_GRADIENT | DC_SMALLCAP",
148 DC_GRADIENT | DC_SMALLCAP);
149 break;
150 case 6:
152 L"DC_GRADIENT | DC_BUTTONS",
153 DC_GRADIENT | DC_BUTTONS);
154 break;
155 case 7:
157 L"DC_BUTTONS | DC_SMALLCAP",
158 DC_BUTTONS | DC_SMALLCAP);
159 break;
160 case 8:
162 L"DC_BUTTONS | DC_SMALLCAP | DC_GRADIENT",
163 DC_BUTTONS | DC_SMALLCAP | DC_GRADIENT);
164 break;
165 }
166
167 EndPaint(hWnd, &Ps);
168
169 return 0;
170 }
171
172 case WM_DESTROY:
173 {
175 return 0;
176 }
177 }
178
180}
#define msg(x)
Definition: auth_time.c:54
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
INT testnum
Definition: drawcap.c:26
VOID DrawCaptionTest(HWND hWnd, HDC hDc, WCHAR *AddonStr, DWORD Addon)
Definition: drawcap.c:65
static HDC
Definition: imagelist.c:92
#define DefWindowProc
Definition: ros2win.h:31
#define TRANSPARENT
Definition: wingdi.h:950
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
#define WM_PAINT
Definition: winuser.h:1620
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
#define WM_DESTROY
Definition: winuser.h:1609
#define DC_SMALLCAP
Definition: winuser.h:428
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)

Referenced by wmain().

◆ DrawCaptionTest()

VOID DrawCaptionTest ( HWND  hWnd,
HDC  hDc,
WCHAR AddonStr,
DWORD  Addon 
)

Definition at line 65 of file drawcap.c.

66{
67 RECT Rect;
69 Rect.bottom = 30;
70 Rect.left = 10;
71 Rect.right-=10;
72 Rect.top = 10;
73
74 CapTest(hWnd, hDc, &Rect, L"DC_TEXT:", DC_TEXT, AddonStr, Addon);
75
76 CapTest(hWnd, hDc, &Rect,
77 L"DC_TEXT | DC_ACTIVE:",
79 AddonStr, Addon);
80
81 CapTest(hWnd, hDc, &Rect,
82 L"DC_TEXT | DC_ICON:" ,
84 AddonStr, Addon);
85
86 CapTest(hWnd, hDc, &Rect,
87 L"DC_TEXT | DC_ACTIVE | DC_ICON:" ,
89 AddonStr, Addon);
90
91 CapTest(hWnd, hDc, &Rect,
92 L"DC_TEXT | DC_INBUTTON:" ,
94 AddonStr, Addon);
95
96 CapTest(hWnd, hDc, &Rect,
97 L"DC_TEXT | DC_ACTIVE | DC_INBUTTON:" ,
99 AddonStr, Addon);
100
101 CapTest(hWnd, hDc, &Rect,
102 L"DC_TEXT | DC_ICON | DC_INBUTTON:" ,
104 AddonStr, Addon);
105
106 CapTest(hWnd, hDc, &Rect,
107 L"DC_TEXT | DC_ACTIVE | DC_ICON | DC_INBUTTON:" ,
109 AddonStr, Addon);
110
111}
#define DC_ACTIVE
Definition: dc21x4.h:120
VOID CapTest(HWND hWnd, HDC hDc, LPRECT pR, WCHAR *Text, DWORD Flags, WCHAR *AddonStr, DWORD Addon)
Definition: drawcap.c:37
#define DC_INBUTTON
Definition: winuser.h:431
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define DC_TEXT
Definition: winuser.h:430
#define DC_ICON
Definition: winuser.h:429

Referenced by CaptWndProc().

◆ wmain()

int wmain ( int  argc,
wchar_t **  argv 
)

Definition at line 183 of file drawcap.c.

184{
185 HWND hWnd;
186 MSG msg;
187 WNDCLASSEX wcx;
188 UINT result;
189 HBRUSH hBr;
190 //HMODULE hLib;
191
192 if(argc<2)
193 {
194 printf("DrawCaption testcode.\n");
195 printf("USAGE: drawcap.exe <testnumber> [useicon]\n\n");
196 printf("Available tests:\n"
197 "1. DrawCaption test\n"
198 "2. DrawCaption test + DC_GRADIENT\n"
199 "3. DrawCaption test + DC_SMALLCAP\n"
200 "4. DrawCaption test + DC_BUTTONS\n"
201 "5. DrawCaption test + DC_GRADIENT | DC_SMALLCAP\n"
202 "6. DrawCaption test + DC_GRADIENT | DC_BUTTONS\n"
203 "7. DrawCaption test + DC_BUTTONS | DC_SMALLCAP\n"
204 "8. DrawCaption test + DC_BUTTONS | DC_SMALLCAP | DC_GRADIENT\n\n");
205 return 0;
206 }
207
208 testnum = _wtoi(argv[1]);
209 if(testnum < 1 || testnum > 8)
210 {
211 printf("Unknown test %d\n", testnum);
212 return 1;
213 }
214
216
217 //hLib = LoadLibrary(L"user32");
218 //if(!hLib)
219 //{
220 // printf("Shit! Can't load user32.dll\n");
221 // return 1;
222 //}
223
224 //DrawCaptionTemp = GetProcAddress(hLib, "DrawCaptionTempW");
225 //if(!DrawCaptionTemp)
226 //{
227 // printf("Shit! Can't get DrawCaptionTemp address\n");
228 // return 1;
229 //}
230
231 hBr = CreateSolidBrush(RGB(255, 255, 255));
232 if(!hBr)
233 {
234 printf("Shit! Can't create brush.");
235 return 1;
236 }
237
238 memset(&wcx, 0, sizeof(wcx));
239 wcx.cbSize = sizeof(wcx);
242 wcx.hInstance = hInst;
243 wcx.hbrBackground = hBr;
246
247 if(!(result = RegisterClassEx(&wcx)))
248 {
249 printf("Shit! RegisterClassEx failed: %d\n",
250 (int)GetLastError());
251 DeleteObject(hBr);
252 return 1;
253 }
254
257 L"DrawCaption test",
261 600,
262 470,
263 NULL,
264 0,
265 hInst,
266 NULL);
267
268 if(!hWnd)
269 {
270 printf("Shit! Can't create wnd!\n");
272 DeleteObject(hBr);
273 return 1;
274 }
275
276
279
280 while(GetMessage(&msg, NULL, 0, 0 ))
281 {
284 }
285
286 DeleteObject(hBr);
288 return 0;
289}
static int argc
Definition: ServiceArgs.c:12
#define NULL
Definition: types.h:112
HINSTANCE hInst
Definition: drawcap.c:25
WCHAR CaptWndClass[]
Definition: drawcap.c:23
LRESULT CALLBACK CaptWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: drawcap.c:113
#define RGB(r, g, b)
Definition: precomp.h:71
pKey DeleteObject()
GLuint64EXT * result
Definition: glext.h:11304
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
#define ID_ICON1SM
Definition: resource.h:5
#define argv
Definition: mplay32.c:18
unsigned int UINT
Definition: ndis.h:50
#define WS_OVERLAPPED
Definition: pedump.c:615
#define WS_SYSMENU
Definition: pedump.c:629
#define WS_THICKFRAME
Definition: pedump.c:630
#define memset(x, y, z)
Definition: compat.h:39
HINSTANCE hInstance
Definition: winuser.h:3206
HICON hIconSm
Definition: winuser.h:3212
UINT style
Definition: winuser.h:3202
UINT cbSize
Definition: winuser.h:3201
WNDPROC lpfnWndProc
Definition: winuser.h:3203
LPCSTR lpszClassName
Definition: winuser.h:3211
HBRUSH hbrBackground
Definition: winuser.h:3209
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
#define GetModuleHandle
Definition: winbase.h:3762
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
#define CS_VREDRAW
Definition: winuser.h:658
#define CreateWindowEx
Definition: winuser.h:5755
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define CS_HREDRAW
Definition: winuser.h:653
#define UnregisterClass
Definition: winuser.h:5861
#define GetMessage
Definition: winuser.h:5790
#define RegisterClassEx
Definition: winuser.h:5837
#define LoadIcon
Definition: winuser.h:5813
BOOL WINAPI UpdateWindow(_In_ HWND)
#define CW_USEDEFAULT
Definition: winuser.h:225
#define SW_SHOW
Definition: winuser.h:775
#define DispatchMessage
Definition: winuser.h:5765
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2906
#define MAKEINTRESOURCE
Definition: winuser.h:591

Variable Documentation

◆ CaptWndClass

WCHAR CaptWndClass[] = L"captwnd_class"

Definition at line 23 of file drawcap.c.

Referenced by wmain().

◆ hInst

HINSTANCE hInst

Definition at line 25 of file drawcap.c.

Referenced by wmain().

◆ testnum

INT testnum = 0

Definition at line 26 of file drawcap.c.

Referenced by CaptWndProc(), and wmain().