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