]>
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 | ||
7344726a VZ |
46 | // CreateWindow |
47 | ||
48 | #if defined(CreateWindow) | |
49 | #undef CreateWindow | |
50 | ||
51 | inline HWND CreateWindow(LPCTSTR lpClassName, | |
52 | LPCTSTR lpWndClass, | |
53 | DWORD dwStyle, | |
54 | int x, int y, int w, int h, | |
55 | HWND hWndParent, | |
56 | HMENU hMenu, | |
57 | HINSTANCE hInstance, | |
58 | LPVOID lpParam) | |
59 | { | |
60 | #ifdef _UNICODE | |
61 | return CreateWindowW(lpClassName, lpWndClass, dwStyle, x, y, w, h, | |
62 | hWndParent, hMenu, hInstance, lpParam); | |
63 | #else | |
64 | return CreateWindowA(lpClassName, lpWndClass, dwStyle, x, y, w, h, | |
65 | hWndParent, hMenu, hInstance, lpParam); | |
66 | #endif | |
67 | } | |
68 | #endif | |
69 | ||
731db709 VZ |
70 | // LoadMenu |
71 | ||
72 | #ifdef LoadMenu | |
73 | #undef LoadMenu | |
74 | ||
75 | inline HMENU LoadMenu(HINSTANCE instance, LPCTSTR name) | |
76 | { | |
77 | #ifdef _UNICODE | |
78 | return LoadMenuW(instance, name); | |
79 | #else | |
80 | return LoadMenuA(instance, name); | |
81 | #endif | |
82 | } | |
83 | #endif | |
84 | ||
2b5f62a0 VZ |
85 | // FindText |
86 | ||
87 | #ifdef FindText | |
88 | #undef FindText | |
89 | ||
90 | inline HWND APIENTRY FindText(LPFINDREPLACE lpfindreplace) | |
91 | { | |
92 | #ifdef UNICODE | |
93 | return FindTextW(lpfindreplace); | |
94 | #else | |
95 | return FindTextA(lpfindreplace); | |
96 | #endif // !UNICODE | |
97 | } | |
98 | #endif | |
99 | ||
6bbd3344 BM |
100 | // GetCharWidth |
101 | ||
98216d40 | 102 | #ifdef GetCharWidth |
379a3b04 BM |
103 | #undef GetCharWidth |
104 | inline BOOL GetCharWidth(HDC dc, UINT first, UINT last, LPINT buffer) | |
105 | { | |
106 | #ifdef _UNICODE | |
107 | return GetCharWidthW(dc, first, last, buffer); | |
108 | #else | |
109 | return GetCharWidthA(dc, first, last, buffer); | |
110 | #endif | |
111 | } | |
e90babdf | 112 | #endif |
6bbd3344 BM |
113 | |
114 | // FindWindow | |
115 | ||
98216d40 | 116 | #ifdef FindWindow |
379a3b04 BM |
117 | #undef FindWindow |
118 | #ifdef _UNICODE | |
119 | inline HWND FindWindow(LPCWSTR classname, LPCWSTR windowname) | |
120 | { | |
121 | return FindWindowW(classname, windowname); | |
122 | } | |
123 | #else | |
124 | inline HWND FindWindow(LPCSTR classname, LPCSTR windowname) | |
125 | { | |
126 | return FindWindowA(classname, windowname); | |
127 | } | |
128 | #endif | |
e90babdf | 129 | #endif |
6bbd3344 | 130 | |
13ff9344 JS |
131 | // PlaySound |
132 | ||
133 | #ifdef PlaySound | |
134 | #undef PlaySound | |
135 | #ifdef _UNICODE | |
136 | inline BOOL PlaySound(LPCWSTR pszSound, HMODULE hMod, DWORD fdwSound) | |
137 | { | |
138 | return PlaySoundW(pszSound, hMod, fdwSound); | |
139 | } | |
140 | #else | |
141 | inline BOOL PlaySound(LPCSTR pszSound, HMODULE hMod, DWORD fdwSound) | |
142 | { | |
143 | return PlaySoundA(pszSound, hMod, fdwSound); | |
144 | } | |
145 | #endif | |
146 | #endif | |
147 | ||
6bbd3344 BM |
148 | // GetClassName |
149 | ||
98216d40 | 150 | #ifdef GetClassName |
379a3b04 BM |
151 | #undef GetClassName |
152 | #ifdef _UNICODE | |
153 | inline int GetClassName(HWND h, LPWSTR classname, int maxcount) | |
154 | { | |
155 | return GetClassNameW(h, classname, maxcount); | |
156 | } | |
157 | #else | |
158 | inline int GetClassName(HWND h, LPSTR classname, int maxcount) | |
159 | { | |
160 | return GetClassNameA(h, classname, maxcount); | |
161 | } | |
162 | #endif | |
e90babdf | 163 | #endif |
6bbd3344 BM |
164 | |
165 | // GetClassInfo | |
166 | ||
98216d40 | 167 | #ifdef GetClassInfo |
379a3b04 BM |
168 | #undef GetClassInfo |
169 | #ifdef _UNICODE | |
170 | inline BOOL GetClassInfo(HINSTANCE h, LPCWSTR name, LPWNDCLASSW winclass) | |
171 | { | |
172 | return GetClassInfoW(h, name, winclass); | |
173 | } | |
174 | #else | |
175 | inline BOOL GetClassInfo(HINSTANCE h, LPCSTR name, LPWNDCLASSA winclass) | |
176 | { | |
177 | return GetClassInfoA(h, name, winclass); | |
178 | } | |
179 | #endif | |
e90babdf | 180 | #endif |
6bbd3344 BM |
181 | |
182 | // LoadAccelerators | |
183 | ||
98216d40 | 184 | #ifdef LoadAccelerators |
379a3b04 BM |
185 | #undef LoadAccelerators |
186 | #ifdef _UNICODE | |
187 | inline HACCEL LoadAccelerators(HINSTANCE h, LPCWSTR name) | |
188 | { | |
189 | return LoadAcceleratorsW(h, name); | |
190 | } | |
191 | #else | |
192 | inline HACCEL LoadAccelerators(HINSTANCE h, LPCSTR name) | |
193 | { | |
194 | return LoadAcceleratorsA(h, name); | |
195 | } | |
196 | #endif | |
98216d40 | 197 | #endif |
6bbd3344 BM |
198 | |
199 | // DrawText | |
200 | ||
98216d40 | 201 | #ifdef DrawText |
379a3b04 BM |
202 | #undef DrawText |
203 | #ifdef _UNICODE | |
204 | inline int DrawText(HDC h, LPCWSTR str, int count, LPRECT rect, UINT format) | |
205 | { | |
206 | return DrawTextW(h, str, count, rect, format); | |
207 | } | |
208 | #else | |
209 | inline int DrawText(HDC h, LPCSTR str, int count, LPRECT rect, UINT format) | |
210 | { | |
211 | return DrawTextA(h, str, count, rect, format); | |
212 | } | |
213 | #endif | |
e90babdf | 214 | #endif |
6bbd3344 | 215 | |
4ccf704a VZ |
216 | |
217 | /* | |
218 | When this file is included, sometimes the wxCHECK_W32API_VERSION macro | |
219 | is undefined. With for example CodeWarrior this gives problems with | |
220 | the following code: | |
221 | #if 0 && wxCHECK_W32API_VERSION( 0, 5 ) | |
222 | Because CodeWarrior does macro expansion before test evaluation. | |
223 | We define wxCHECK_W32API_VERSION here if it's undefined. | |
224 | */ | |
225 | #if !defined(__GNUG__) && !defined(wxCHECK_W32API_VERSION) | |
226 | #define wxCHECK_W32API_VERSION(maj, min) (0) | |
227 | #endif | |
228 | ||
6bbd3344 BM |
229 | // StartDoc |
230 | ||
98216d40 | 231 | #ifdef StartDoc |
379a3b04 | 232 | #undef StartDoc |
d8c72298 | 233 | #if defined( __GNUG__ ) && !wxCHECK_W32API_VERSION( 0, 5 ) |
0c589ad0 BM |
234 | #define DOCINFOW DOCINFO |
235 | #define DOCINFOA DOCINFO | |
236 | #endif | |
379a3b04 BM |
237 | #ifdef _UNICODE |
238 | inline int StartDoc(HDC h, CONST DOCINFOW* info) | |
239 | { | |
d8c72298 | 240 | return StartDocW(h, (DOCINFOW*) info); |
379a3b04 BM |
241 | } |
242 | #else | |
243 | inline int StartDoc(HDC h, CONST DOCINFOA* info) | |
244 | { | |
d8c72298 | 245 | return StartDocA(h, (DOCINFOA*) info); |
379a3b04 BM |
246 | } |
247 | #endif | |
98216d40 VZ |
248 | #endif |
249 | ||
379a3b04 BM |
250 | // GetObject |
251 | ||
252 | #ifdef GetObject | |
253 | #undef GetObject | |
254 | inline int GetObject(HGDIOBJ h, int i, LPVOID buffer) | |
255 | { | |
256 | #ifdef _UNICODE | |
257 | return GetObjectW(h, i, buffer); | |
258 | #else | |
259 | return GetObjectA(h, i, buffer); | |
6ec9d18f RD |
260 | #endif |
261 | } | |
262 | #endif | |
263 | ||
7cc98b3e | 264 | // GetMessage |
6ec9d18f RD |
265 | |
266 | #ifdef GetMessage | |
267 | #undef GetMessage | |
268 | inline int GetMessage(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax) | |
269 | { | |
270 | #ifdef _UNICODE | |
271 | return GetMessageW(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax); | |
272 | #else | |
273 | return GetMessageA(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax); | |
274 | #endif | |
379a3b04 | 275 | } |
e90babdf | 276 | #endif |
98216d40 | 277 | |
8b39c006 VZ |
278 | // LoadIcon |
279 | #ifdef LoadIcon | |
280 | #undef LoadIcon | |
5e2411ab | 281 | inline HICON LoadIcon(HINSTANCE hInstance, LPCTSTR lpIconName) |
8b39c006 VZ |
282 | { |
283 | #ifdef _UNICODE | |
284 | return LoadIconW(hInstance, lpIconName); | |
285 | #else // ANSI | |
286 | return LoadIconA(hInstance, lpIconName); | |
287 | #endif // Unicode/ANSI | |
288 | } | |
289 | #endif // LoadIcon | |
290 | ||
381adb74 VZ |
291 | // LoadBitmap |
292 | #ifdef LoadBitmap | |
293 | #undef LoadBitmap | |
294 | inline HBITMAP LoadBitmap(HINSTANCE hInstance, LPCTSTR lpBitmapName) | |
295 | { | |
296 | #ifdef _UNICODE | |
297 | return LoadBitmapW(hInstance, lpBitmapName); | |
298 | #else // ANSI | |
299 | return LoadBitmapA(hInstance, lpBitmapName); | |
300 | #endif // Unicode/ANSI | |
301 | } | |
302 | #endif // LoadBitmap | |
8b39c006 | 303 | |
7cc98b3e VZ |
304 | // LoadLibrary |
305 | ||
306 | #ifdef LoadLibrary | |
307 | #undef LoadLibrary | |
7cc98b3e | 308 | #ifdef _UNICODE |
f6bcfd97 BP |
309 | inline HINSTANCE LoadLibrary(LPCWSTR lpLibFileName) |
310 | { | |
7cc98b3e | 311 | return LoadLibraryW(lpLibFileName); |
f6bcfd97 | 312 | } |
7cc98b3e | 313 | #else |
f6bcfd97 BP |
314 | inline HINSTANCE LoadLibrary(LPCSTR lpLibFileName) |
315 | { | |
7cc98b3e | 316 | return LoadLibraryA(lpLibFileName); |
7cc98b3e | 317 | } |
f6bcfd97 | 318 | #endif |
7cc98b3e VZ |
319 | #endif |
320 | ||
b568d04f VZ |
321 | // FindResource |
322 | #ifdef FindResource | |
323 | #undef FindResource | |
b568d04f | 324 | #ifdef _UNICODE |
f6bcfd97 BP |
325 | inline HRSRC FindResource(HMODULE hModule, LPCWSTR lpName, LPCWSTR lpType) |
326 | { | |
b568d04f | 327 | return FindResourceW(hModule, lpName, lpType); |
f6bcfd97 | 328 | } |
b568d04f | 329 | #else |
f6bcfd97 BP |
330 | inline HRSRC FindResource(HMODULE hModule, LPCSTR lpName, LPCSTR lpType) |
331 | { | |
b568d04f | 332 | return FindResourceA(hModule, lpName, lpType); |
b568d04f | 333 | } |
f6bcfd97 | 334 | #endif |
b568d04f VZ |
335 | #endif |
336 | ||
3372145d PA |
337 | // IsMaximized |
338 | ||
339 | #ifdef IsMaximized | |
340 | #undef IsMaximized | |
0c0d1521 | 341 | inline BOOL IsMaximized(HWND WXUNUSED_IN_WINCE(hwnd)) |
3372145d | 342 | { |
42d11c8e JS |
343 | #ifdef __WXWINCE__ |
344 | return FALSE; | |
345 | #else | |
3372145d | 346 | return IsZoomed(hwnd); |
42d11c8e | 347 | #endif |
3372145d PA |
348 | } |
349 | #endif | |
350 | ||
2ba3d4f0 PA |
351 | // GetFirstChild |
352 | ||
353 | #ifdef GetFirstChild | |
354 | #undef GetFirstChild | |
0c0d1521 | 355 | inline HWND GetFirstChild(HWND WXUNUSED_IN_WINCE(hwnd)) |
2ba3d4f0 | 356 | { |
42d11c8e JS |
357 | #ifdef __WXWINCE__ |
358 | return 0; | |
359 | #else | |
2ba3d4f0 | 360 | return GetTopWindow(hwnd); |
42d11c8e | 361 | #endif |
2ba3d4f0 PA |
362 | } |
363 | #endif | |
364 | ||
79bc2382 PA |
365 | // GetPrevSibling |
366 | ||
367 | #ifdef GetPrevSibling | |
368 | #undef GetPrevSibling | |
369 | inline HWND GetPrevSibling(HWND hwnd) | |
370 | { | |
371 | return GetWindow(hwnd,GW_HWNDPREV); | |
372 | } | |
373 | #endif | |
374 | ||
375 | // GetNextSibling | |
376 | ||
377 | #ifdef GetNextSibling | |
378 | #undef GetNextSibling | |
379 | inline HWND GetNextSibling(HWND hwnd) | |
380 | { | |
381 | return GetWindow(hwnd,GW_HWNDNEXT); | |
382 | } | |
383 | #endif | |
384 | ||
c455ab93 RR |
385 | // For WINE |
386 | ||
b4da152e | 387 | #if defined(GetWindowStyle) |
c455ab93 RR |
388 | #undef GetWindowStyle |
389 | #endif | |
98216d40 | 390 | |
379a3b04 | 391 | // For ming and cygwin |
6bbd3344 | 392 | |
379a3b04 BM |
393 | // GetFirstChild |
394 | #ifdef GetFirstChild | |
395 | #undef GetFirstChild | |
396 | inline HWND GetFirstChild(HWND h) | |
397 | { | |
398 | return GetTopWindow(h); | |
399 | } | |
400 | #endif | |
6bbd3344 | 401 | |
98216d40 | 402 | |
379a3b04 BM |
403 | // GetNextSibling |
404 | #ifdef GetNextSibling | |
0c589ad0 BM |
405 | #undef GetNextSibling |
406 | inline HWND GetNextSibling(HWND h) | |
407 | { | |
408 | return GetWindow(h, GW_HWNDNEXT); | |
409 | } | |
98216d40 VZ |
410 | #endif |
411 | ||
73c13bb9 RD |
412 | |
413 | #ifdef Yield | |
414 | #undef Yield | |
415 | #endif | |
416 | ||
368c9c6d JS |
417 | |
418 | #if defined(__WXWINCE__) && defined(DrawIcon) //#ifdef DrawIcon | |
419 | #undef DrawIcon | |
27d2dbbc | 420 | inline BOOL DrawIcon(HDC hdc, int x, int y, HICON hicon) |
368c9c6d JS |
421 | { |
422 | return DrawIconEx(hdc,x,y,hicon,0,0,0,NULL, DI_NORMAL) ; | |
423 | } | |
424 | #endif | |
425 | ||
426 | ||
379a3b04 BM |
427 | // GetWindowProc |
428 | //ifdef GetWindowProc | |
429 | // #undef GetWindowProc | |
430 | //endif | |
431 | //ifdef GetNextChild | |
432 | // #undef GetNextChild | |
433 | //endif | |
6bbd3344 | 434 | |
25889d3c JS |
435 | // #endif // _WX_WINUNDEF_H_ |
436 |