2 * Copyright 2006 Saveliy Tretiakov
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.
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.
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.
23 WCHAR CaptWndClass
[] = L
"captwnd_class";
28 //BOOL WINAPI (*DrawCaptionTemp) (
37 VOID
CapTest(HWND hWnd
,
47 lstrcpy(Buf
, AddonStr
);
48 if(lstrlen(Buf
))lstrcat(Buf
, L
" | ");
51 DrawText( hDc
, Buf
, lstrlen(Buf
), pR
, DT_LEFT
);
56 if(!DrawCaption(hWnd
, hDc
, pR
, Flags
| Addon
))
58 printf("PAINT: DrawCaption failed: %d\n", (int)GetLastError());
65 VOID
DrawCaptionTest(HWND hWnd
, HDC hDc
, WCHAR
*AddonStr
, DWORD Addon
)
68 GetClientRect(hWnd
, &Rect
);
74 CapTest(hWnd
, hDc
, &Rect
, L
"DC_TEXT:", DC_TEXT
, AddonStr
, Addon
);
76 CapTest(hWnd
, hDc
, &Rect
,
77 L
"DC_TEXT | DC_ACTIVE:",
81 CapTest(hWnd
, hDc
, &Rect
,
82 L
"DC_TEXT | DC_ICON:" ,
86 CapTest(hWnd
, hDc
, &Rect
,
87 L
"DC_TEXT | DC_ACTIVE | DC_ICON:" ,
88 DC_TEXT
| DC_ACTIVE
| DC_ICON
,
91 CapTest(hWnd
, hDc
, &Rect
,
92 L
"DC_TEXT | DC_INBUTTON:" ,
93 DC_TEXT
| DC_INBUTTON
,
96 CapTest(hWnd
, hDc
, &Rect
,
97 L
"DC_TEXT | DC_ACTIVE | DC_INBUTTON:" ,
98 DC_TEXT
| DC_ACTIVE
| DC_INBUTTON
,
101 CapTest(hWnd
, hDc
, &Rect
,
102 L
"DC_TEXT | DC_ICON | DC_INBUTTON:" ,
103 DC_TEXT
| DC_ICON
| DC_INBUTTON
,
106 CapTest(hWnd
, hDc
, &Rect
,
107 L
"DC_TEXT | DC_ACTIVE | DC_ICON | DC_INBUTTON:" ,
108 DC_TEXT
| DC_ACTIVE
| DC_ICON
| DC_INBUTTON
,
113 LRESULT CALLBACK
CaptWndProc(HWND hWnd
,
128 hDc
= BeginPaint(hWnd
, &Ps
);
129 SetBkMode( hDc
, TRANSPARENT
);
134 DrawCaptionTest(hWnd
, hDc
, L
"", 0);
137 DrawCaptionTest(hWnd
, hDc
, L
"DC_GRADIENT", DC_GRADIENT
);
140 DrawCaptionTest(hWnd
, hDc
, L
"DC_SMALLCAP", DC_SMALLCAP
);
143 DrawCaptionTest(hWnd
, hDc
, L
"DC_BUTTONS", DC_BUTTONS
);
146 DrawCaptionTest(hWnd
, hDc
,
147 L
"DC_GRADIENT | DC_SMALLCAP",
148 DC_GRADIENT
| DC_SMALLCAP
);
151 DrawCaptionTest(hWnd
, hDc
,
152 L
"DC_GRADIENT | DC_BUTTONS",
153 DC_GRADIENT
| DC_BUTTONS
);
156 DrawCaptionTest(hWnd
, hDc
,
157 L
"DC_BUTTONS | DC_SMALLCAP",
158 DC_BUTTONS
| DC_SMALLCAP
);
161 DrawCaptionTest(hWnd
, hDc
,
162 L
"DC_BUTTONS | DC_SMALLCAP | DC_GRADIENT",
163 DC_BUTTONS
| DC_SMALLCAP
| DC_GRADIENT
);
179 return DefWindowProc(hWnd
, msg
, wParam
, lParam
);
183 int wmain(int argc
, wchar_t**argv
)
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");
208 testnum
= _wtoi(argv
[1]);
209 if(testnum
< 1 || testnum
> 8)
211 printf("Unknown test %d\n", testnum
);
215 hInst
= GetModuleHandle(NULL
);
217 //hLib = LoadLibrary(L"user32");
220 // printf("Shit! Can't load user32.dll\n");
224 //DrawCaptionTemp = GetProcAddress(hLib, "DrawCaptionTempW");
225 //if(!DrawCaptionTemp)
227 // printf("Shit! Can't get DrawCaptionTemp address\n");
231 hBr
= CreateSolidBrush(RGB(255, 255, 255));
234 printf("Shit! Can't create brush.");
238 memset(&wcx
, 0, sizeof(wcx
));
239 wcx
.cbSize
= sizeof(wcx
);
240 wcx
.style
= CS_HREDRAW
| CS_VREDRAW
;
241 wcx
.lpfnWndProc
= (WNDPROC
) CaptWndProc
;
242 wcx
.hInstance
= hInst
;
243 wcx
.hbrBackground
= hBr
;
244 wcx
.lpszClassName
= CaptWndClass
;
245 if(argc
> 2) wcx
.hIconSm
= LoadIcon(hInst
, MAKEINTRESOURCE(ID_ICON1SM
));
247 if(!(result
= RegisterClassEx(&wcx
)))
249 printf("Shit! RegisterClassEx failed: %d\n",
250 (int)GetLastError());
255 hWnd
= CreateWindowEx(0,
258 WS_OVERLAPPED
|WS_THICKFRAME
|WS_SYSMENU
,
270 printf("Shit! Can't create wnd!\n");
271 UnregisterClass(CaptWndClass
, hInst
);
277 ShowWindow(hWnd
, SW_SHOW
);
280 while(GetMessage(&msg
, NULL
, 0, 0 ))
282 TranslateMessage(&msg
);
283 DispatchMessage(&msg
);
287 UnregisterClass(CaptWndClass
, hInst
);