]>
Commit | Line | Data |
---|---|---|
98216d40 VZ |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: winundef.h | |
3 | // Purpose: undefine the common symbols #define'd by <windows.h> | |
4 | // Author: Vadim Zeitlin | |
5 | // Modified by: | |
6 | // Created: 16.05.99 | |
7 | // RCS-ID: $Id$ | |
77ffb593 | 8 | // Copyright: (c) wxWidgets team |
65571936 | 9 | // Licence: wxWindows licence |
98216d40 VZ |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
25889d3c JS |
12 | /* THIS SHOULD NOT BE USED since you might include it once e.g. in window.h, |
13 | * then again _AFTER_ you've included windows.h, in which case it won't work | |
14 | * a 2nd time -- JACS | |
98216d40 VZ |
15 | #ifndef _WX_WINUNDEF_H_ |
16 | #define _WX_WINUNDEF_H_ | |
25889d3c | 17 | */ |
98216d40 | 18 | |
7cc98b3e VZ |
19 | // ---------------------------------------------------------------------------- |
20 | // windows.h #defines the following identifiers which are also used in wxWin so | |
21 | // we replace these symbols with the corresponding inline functions and | |
22 | // undefine the macro. | |
23 | // | |
24 | // This looks quite ugly here but allows us to write clear (and correct!) code | |
25 | // elsewhere because the functions, unlike the macros, respect the scope. | |
26 | // ---------------------------------------------------------------------------- | |
6bbd3344 | 27 | |
b225f659 VZ |
28 | // CreateDialog |
29 | ||
fb86251b | 30 | #if defined(CreateDialog) |
b225f659 VZ |
31 | #undef CreateDialog |
32 | ||
33 | inline HWND CreateDialog(HINSTANCE hInstance, | |
34 | LPCTSTR pTemplate, | |
35 | HWND hwndParent, | |
36 | DLGPROC pDlgProc) | |
37 | { | |
38 | #ifdef _UNICODE | |
39 | return CreateDialogW(hInstance, pTemplate, hwndParent, pDlgProc); | |
40 | #else | |
41 | return CreateDialogA(hInstance, pTemplate, hwndParent, pDlgProc); | |
42 | #endif | |
43 | } | |
44 | #endif | |
45 | ||
136b3b19 VZ |
46 | // CreateFont |
47 | ||
48 | #ifdef CreateFont | |
49 | #undef CreateFont | |
50 | ||
51 | inline HFONT CreateFont(int height, | |
52 | int width, | |
53 | int escapement, | |
54 | int orientation, | |
55 | int weight, | |
56 | DWORD italic, | |
57 | DWORD underline, | |
58 | DWORD strikeout, | |
59 | DWORD charset, | |
60 | DWORD outprecision, | |
61 | DWORD clipprecision, | |
62 | DWORD quality, | |
63 | DWORD family, | |
64 | LPCTSTR facename) | |
65 | { | |
66 | #ifdef _UNICODE | |
67 | return CreateFontW(height, width, escapement, orientation, | |
68 | weight, italic, underline, strikeout, charset, | |
69 | outprecision, clipprecision, quality, | |
70 | family, facename); | |
71 | #else | |
72 | return CreateFontA(height, width, escapement, orientation, | |
73 | weight, italic, underline, strikeout, charset, | |
74 | outprecision, clipprecision, quality, | |
75 | family, facename); | |
76 | #endif | |
77 | } | |
78 | #endif // CreateFont | |
79 | ||
7344726a VZ |
80 | // CreateWindow |
81 | ||
82 | #if defined(CreateWindow) | |
83 | #undef CreateWindow | |
84 | ||
85 | inline HWND CreateWindow(LPCTSTR lpClassName, | |
86 | LPCTSTR lpWndClass, | |
87 | DWORD dwStyle, | |
88 | int x, int y, int w, int h, | |
89 | HWND hWndParent, | |
90 | HMENU hMenu, | |
91 | HINSTANCE hInstance, | |
92 | LPVOID lpParam) | |
93 | { | |
94 | #ifdef _UNICODE | |
95 | return CreateWindowW(lpClassName, lpWndClass, dwStyle, x, y, w, h, | |
96 | hWndParent, hMenu, hInstance, lpParam); | |
97 | #else | |
98 | return CreateWindowA(lpClassName, lpWndClass, dwStyle, x, y, w, h, | |
99 | hWndParent, hMenu, hInstance, lpParam); | |
100 | #endif | |
101 | } | |
102 | #endif | |
103 | ||
731db709 VZ |
104 | // LoadMenu |
105 | ||
106 | #ifdef LoadMenu | |
107 | #undef LoadMenu | |
108 | ||
109 | inline HMENU LoadMenu(HINSTANCE instance, LPCTSTR name) | |
110 | { | |
111 | #ifdef _UNICODE | |
112 | return LoadMenuW(instance, name); | |
113 | #else | |
114 | return LoadMenuA(instance, name); | |
115 | #endif | |
116 | } | |
117 | #endif | |
118 | ||
2b5f62a0 VZ |
119 | // FindText |
120 | ||
121 | #ifdef FindText | |
122 | #undef FindText | |
123 | ||
124 | inline HWND APIENTRY FindText(LPFINDREPLACE lpfindreplace) | |
125 | { | |
126 | #ifdef UNICODE | |
127 | return FindTextW(lpfindreplace); | |
128 | #else | |
129 | return FindTextA(lpfindreplace); | |
130 | #endif // !UNICODE | |
131 | } | |
132 | #endif | |
133 | ||
6bbd3344 BM |
134 | // GetCharWidth |
135 | ||
98216d40 | 136 | #ifdef GetCharWidth |
379a3b04 BM |
137 | #undef GetCharWidth |
138 | inline BOOL GetCharWidth(HDC dc, UINT first, UINT last, LPINT buffer) | |
139 | { | |
140 | #ifdef _UNICODE | |
141 | return GetCharWidthW(dc, first, last, buffer); | |
142 | #else | |
143 | return GetCharWidthA(dc, first, last, buffer); | |
144 | #endif | |
145 | } | |
e90babdf | 146 | #endif |
6bbd3344 BM |
147 | |
148 | // FindWindow | |
149 | ||
98216d40 | 150 | #ifdef FindWindow |
379a3b04 BM |
151 | #undef FindWindow |
152 | #ifdef _UNICODE | |
153 | inline HWND FindWindow(LPCWSTR classname, LPCWSTR windowname) | |
154 | { | |
155 | return FindWindowW(classname, windowname); | |
156 | } | |
157 | #else | |
158 | inline HWND FindWindow(LPCSTR classname, LPCSTR windowname) | |
159 | { | |
160 | return FindWindowA(classname, windowname); | |
161 | } | |
162 | #endif | |
e90babdf | 163 | #endif |
6bbd3344 | 164 | |
13ff9344 JS |
165 | // PlaySound |
166 | ||
167 | #ifdef PlaySound | |
168 | #undef PlaySound | |
169 | #ifdef _UNICODE | |
170 | inline BOOL PlaySound(LPCWSTR pszSound, HMODULE hMod, DWORD fdwSound) | |
171 | { | |
172 | return PlaySoundW(pszSound, hMod, fdwSound); | |
173 | } | |
174 | #else | |
175 | inline BOOL PlaySound(LPCSTR pszSound, HMODULE hMod, DWORD fdwSound) | |
176 | { | |
177 | return PlaySoundA(pszSound, hMod, fdwSound); | |
178 | } | |
179 | #endif | |
180 | #endif | |
181 | ||
6bbd3344 BM |
182 | // GetClassName |
183 | ||
98216d40 | 184 | #ifdef GetClassName |
379a3b04 BM |
185 | #undef GetClassName |
186 | #ifdef _UNICODE | |
187 | inline int GetClassName(HWND h, LPWSTR classname, int maxcount) | |
188 | { | |
189 | return GetClassNameW(h, classname, maxcount); | |
190 | } | |
191 | #else | |
192 | inline int GetClassName(HWND h, LPSTR classname, int maxcount) | |
193 | { | |
194 | return GetClassNameA(h, classname, maxcount); | |
195 | } | |
196 | #endif | |
e90babdf | 197 | #endif |
6bbd3344 BM |
198 | |
199 | // GetClassInfo | |
200 | ||
98216d40 | 201 | #ifdef GetClassInfo |
379a3b04 BM |
202 | #undef GetClassInfo |
203 | #ifdef _UNICODE | |
204 | inline BOOL GetClassInfo(HINSTANCE h, LPCWSTR name, LPWNDCLASSW winclass) | |
205 | { | |
206 | return GetClassInfoW(h, name, winclass); | |
207 | } | |
208 | #else | |
209 | inline BOOL GetClassInfo(HINSTANCE h, LPCSTR name, LPWNDCLASSA winclass) | |
210 | { | |
211 | return GetClassInfoA(h, name, winclass); | |
212 | } | |
213 | #endif | |
e90babdf | 214 | #endif |
6bbd3344 BM |
215 | |
216 | // LoadAccelerators | |
217 | ||
98216d40 | 218 | #ifdef LoadAccelerators |
379a3b04 BM |
219 | #undef LoadAccelerators |
220 | #ifdef _UNICODE | |
221 | inline HACCEL LoadAccelerators(HINSTANCE h, LPCWSTR name) | |
222 | { | |
223 | return LoadAcceleratorsW(h, name); | |
224 | } | |
225 | #else | |
226 | inline HACCEL LoadAccelerators(HINSTANCE h, LPCSTR name) | |
227 | { | |
228 | return LoadAcceleratorsA(h, name); | |
229 | } | |
230 | #endif | |
98216d40 | 231 | #endif |
6bbd3344 BM |
232 | |
233 | // DrawText | |
234 | ||
98216d40 | 235 | #ifdef DrawText |
379a3b04 BM |
236 | #undef DrawText |
237 | #ifdef _UNICODE | |
238 | inline int DrawText(HDC h, LPCWSTR str, int count, LPRECT rect, UINT format) | |
239 | { | |
240 | return DrawTextW(h, str, count, rect, format); | |
241 | } | |
242 | #else | |
243 | inline int DrawText(HDC h, LPCSTR str, int count, LPRECT rect, UINT format) | |
244 | { | |
245 | return DrawTextA(h, str, count, rect, format); | |
246 | } | |
247 | #endif | |
e90babdf | 248 | #endif |
6bbd3344 | 249 | |
4ccf704a VZ |
250 | |
251 | /* | |
252 | When this file is included, sometimes the wxCHECK_W32API_VERSION macro | |
253 | is undefined. With for example CodeWarrior this gives problems with | |
254 | the following code: | |
255 | #if 0 && wxCHECK_W32API_VERSION( 0, 5 ) | |
256 | Because CodeWarrior does macro expansion before test evaluation. | |
257 | We define wxCHECK_W32API_VERSION here if it's undefined. | |
258 | */ | |
259 | #if !defined(__GNUG__) && !defined(wxCHECK_W32API_VERSION) | |
260 | #define wxCHECK_W32API_VERSION(maj, min) (0) | |
261 | #endif | |
262 | ||
6bbd3344 BM |
263 | // StartDoc |
264 | ||
98216d40 | 265 | #ifdef StartDoc |
379a3b04 | 266 | #undef StartDoc |
d8c72298 | 267 | #if defined( __GNUG__ ) && !wxCHECK_W32API_VERSION( 0, 5 ) |
0c589ad0 BM |
268 | #define DOCINFOW DOCINFO |
269 | #define DOCINFOA DOCINFO | |
270 | #endif | |
379a3b04 BM |
271 | #ifdef _UNICODE |
272 | inline int StartDoc(HDC h, CONST DOCINFOW* info) | |
273 | { | |
d8c72298 | 274 | return StartDocW(h, (DOCINFOW*) info); |
379a3b04 BM |
275 | } |
276 | #else | |
277 | inline int StartDoc(HDC h, CONST DOCINFOA* info) | |
278 | { | |
d8c72298 | 279 | return StartDocA(h, (DOCINFOA*) info); |
379a3b04 BM |
280 | } |
281 | #endif | |
98216d40 VZ |
282 | #endif |
283 | ||
379a3b04 BM |
284 | // GetObject |
285 | ||
286 | #ifdef GetObject | |
287 | #undef GetObject | |
288 | inline int GetObject(HGDIOBJ h, int i, LPVOID buffer) | |
289 | { | |
290 | #ifdef _UNICODE | |
291 | return GetObjectW(h, i, buffer); | |
292 | #else | |
293 | return GetObjectA(h, i, buffer); | |
6ec9d18f RD |
294 | #endif |
295 | } | |
296 | #endif | |
297 | ||
7cc98b3e | 298 | // GetMessage |
6ec9d18f RD |
299 | |
300 | #ifdef GetMessage | |
301 | #undef GetMessage | |
302 | inline int GetMessage(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax) | |
303 | { | |
304 | #ifdef _UNICODE | |
305 | return GetMessageW(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax); | |
306 | #else | |
307 | return GetMessageA(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax); | |
308 | #endif | |
379a3b04 | 309 | } |
e90babdf | 310 | #endif |
98216d40 | 311 | |
8b39c006 VZ |
312 | // LoadIcon |
313 | #ifdef LoadIcon | |
314 | #undef LoadIcon | |
5e2411ab | 315 | inline HICON LoadIcon(HINSTANCE hInstance, LPCTSTR lpIconName) |
8b39c006 VZ |
316 | { |
317 | #ifdef _UNICODE | |
318 | return LoadIconW(hInstance, lpIconName); | |
319 | #else // ANSI | |
320 | return LoadIconA(hInstance, lpIconName); | |
321 | #endif // Unicode/ANSI | |
322 | } | |
323 | #endif // LoadIcon | |
324 | ||
381adb74 VZ |
325 | // LoadBitmap |
326 | #ifdef LoadBitmap | |
327 | #undef LoadBitmap | |
328 | inline HBITMAP LoadBitmap(HINSTANCE hInstance, LPCTSTR lpBitmapName) | |
329 | { | |
330 | #ifdef _UNICODE | |
331 | return LoadBitmapW(hInstance, lpBitmapName); | |
332 | #else // ANSI | |
333 | return LoadBitmapA(hInstance, lpBitmapName); | |
334 | #endif // Unicode/ANSI | |
335 | } | |
336 | #endif // LoadBitmap | |
8b39c006 | 337 | |
7cc98b3e VZ |
338 | // LoadLibrary |
339 | ||
340 | #ifdef LoadLibrary | |
341 | #undef LoadLibrary | |
7cc98b3e | 342 | #ifdef _UNICODE |
f6bcfd97 BP |
343 | inline HINSTANCE LoadLibrary(LPCWSTR lpLibFileName) |
344 | { | |
7cc98b3e | 345 | return LoadLibraryW(lpLibFileName); |
f6bcfd97 | 346 | } |
7cc98b3e | 347 | #else |
f6bcfd97 BP |
348 | inline HINSTANCE LoadLibrary(LPCSTR lpLibFileName) |
349 | { | |
7cc98b3e | 350 | return LoadLibraryA(lpLibFileName); |
7cc98b3e | 351 | } |
f6bcfd97 | 352 | #endif |
7cc98b3e VZ |
353 | #endif |
354 | ||
b568d04f VZ |
355 | // FindResource |
356 | #ifdef FindResource | |
357 | #undef FindResource | |
b568d04f | 358 | #ifdef _UNICODE |
f6bcfd97 BP |
359 | inline HRSRC FindResource(HMODULE hModule, LPCWSTR lpName, LPCWSTR lpType) |
360 | { | |
b568d04f | 361 | return FindResourceW(hModule, lpName, lpType); |
f6bcfd97 | 362 | } |
b568d04f | 363 | #else |
f6bcfd97 BP |
364 | inline HRSRC FindResource(HMODULE hModule, LPCSTR lpName, LPCSTR lpType) |
365 | { | |
b568d04f | 366 | return FindResourceA(hModule, lpName, lpType); |
b568d04f | 367 | } |
f6bcfd97 | 368 | #endif |
b568d04f VZ |
369 | #endif |
370 | ||
3372145d PA |
371 | // IsMaximized |
372 | ||
373 | #ifdef IsMaximized | |
374 | #undef IsMaximized | |
0c0d1521 | 375 | inline BOOL IsMaximized(HWND WXUNUSED_IN_WINCE(hwnd)) |
3372145d | 376 | { |
42d11c8e JS |
377 | #ifdef __WXWINCE__ |
378 | return FALSE; | |
379 | #else | |
3372145d | 380 | return IsZoomed(hwnd); |
42d11c8e | 381 | #endif |
3372145d PA |
382 | } |
383 | #endif | |
384 | ||
2ba3d4f0 PA |
385 | // GetFirstChild |
386 | ||
387 | #ifdef GetFirstChild | |
388 | #undef GetFirstChild | |
0c0d1521 | 389 | inline HWND GetFirstChild(HWND WXUNUSED_IN_WINCE(hwnd)) |
2ba3d4f0 | 390 | { |
42d11c8e JS |
391 | #ifdef __WXWINCE__ |
392 | return 0; | |
393 | #else | |
2ba3d4f0 | 394 | return GetTopWindow(hwnd); |
42d11c8e | 395 | #endif |
2ba3d4f0 PA |
396 | } |
397 | #endif | |
398 | ||
dec531b2 VS |
399 | // GetFirstSibling |
400 | ||
401 | #ifdef GetFirstSibling | |
402 | #undef GetFirstSibling | |
403 | inline HWND GetFirstSibling(HWND hwnd) | |
404 | { | |
405 | return GetWindow(hwnd,GW_HWNDFIRST); | |
406 | } | |
407 | #endif | |
408 | ||
409 | // GetLastSibling | |
410 | ||
411 | #ifdef GetLastSibling | |
412 | #undef GetLastSibling | |
413 | inline HWND GetLastSibling(HWND hwnd) | |
414 | { | |
415 | return GetWindow(hwnd,GW_HWNDLAST); | |
416 | } | |
417 | #endif | |
418 | ||
79bc2382 PA |
419 | // GetPrevSibling |
420 | ||
421 | #ifdef GetPrevSibling | |
422 | #undef GetPrevSibling | |
423 | inline HWND GetPrevSibling(HWND hwnd) | |
424 | { | |
425 | return GetWindow(hwnd,GW_HWNDPREV); | |
426 | } | |
427 | #endif | |
428 | ||
429 | // GetNextSibling | |
430 | ||
431 | #ifdef GetNextSibling | |
432 | #undef GetNextSibling | |
433 | inline HWND GetNextSibling(HWND hwnd) | |
434 | { | |
435 | return GetWindow(hwnd,GW_HWNDNEXT); | |
436 | } | |
437 | #endif | |
438 | ||
c455ab93 RR |
439 | // For WINE |
440 | ||
b4da152e | 441 | #if defined(GetWindowStyle) |
c455ab93 RR |
442 | #undef GetWindowStyle |
443 | #endif | |
98216d40 | 444 | |
379a3b04 | 445 | // For ming and cygwin |
6bbd3344 | 446 | |
379a3b04 BM |
447 | // GetFirstChild |
448 | #ifdef GetFirstChild | |
449 | #undef GetFirstChild | |
450 | inline HWND GetFirstChild(HWND h) | |
451 | { | |
452 | return GetTopWindow(h); | |
453 | } | |
454 | #endif | |
6bbd3344 | 455 | |
98216d40 | 456 | |
379a3b04 BM |
457 | // GetNextSibling |
458 | #ifdef GetNextSibling | |
0c589ad0 BM |
459 | #undef GetNextSibling |
460 | inline HWND GetNextSibling(HWND h) | |
461 | { | |
462 | return GetWindow(h, GW_HWNDNEXT); | |
463 | } | |
98216d40 VZ |
464 | #endif |
465 | ||
73c13bb9 RD |
466 | |
467 | #ifdef Yield | |
468 | #undef Yield | |
469 | #endif | |
470 | ||
368c9c6d JS |
471 | |
472 | #if defined(__WXWINCE__) && defined(DrawIcon) //#ifdef DrawIcon | |
473 | #undef DrawIcon | |
27d2dbbc | 474 | inline BOOL DrawIcon(HDC hdc, int x, int y, HICON hicon) |
368c9c6d JS |
475 | { |
476 | return DrawIconEx(hdc,x,y,hicon,0,0,0,NULL, DI_NORMAL) ; | |
477 | } | |
478 | #endif | |
479 | ||
480 | ||
379a3b04 BM |
481 | // GetWindowProc |
482 | //ifdef GetWindowProc | |
483 | // #undef GetWindowProc | |
484 | //endif | |
485 | //ifdef GetNextChild | |
486 | // #undef GetNextChild | |
487 | //endif | |
6bbd3344 | 488 | |
25889d3c JS |
489 | // #endif // _WX_WINUNDEF_H_ |
490 |