]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/winundef.h
Add wxTranslations::GetBestTranslation().
[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 // RCS-ID: $Id$
8 // Copyright: (c) wxWidgets team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
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
15 #ifndef _WX_WINUNDEF_H_
16 #define _WX_WINUNDEF_H_
17 */
18
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 // ----------------------------------------------------------------------------
27
28 // CreateDialog
29
30 #if defined(CreateDialog)
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
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
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
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
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
131 }
132 #endif
133
134 // GetCharWidth
135
136 #ifdef GetCharWidth
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 }
146 #endif
147
148 // FindWindow
149
150 #ifdef FindWindow
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
163 #endif
164
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
182 // GetClassName
183
184 #ifdef GetClassName
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
197 #endif
198
199 // GetClassInfo
200
201 #ifdef GetClassInfo
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
214 #endif
215
216 // LoadAccelerators
217
218 #ifdef LoadAccelerators
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
231 #endif
232
233 // DrawText
234
235 #ifdef DrawText
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
248 #endif
249
250
251 // StartDoc
252
253 #ifdef StartDoc
254 #undef StartDoc
255
256 // Work around a bug in very old MinGW headers that didn't define DOCINFOW
257 // and DOCINFOA but only DOCINFO in both ANSI and Unicode.
258 #if defined( __GNUG__ )
259 #if !wxCHECK_W32API_VERSION( 0, 5 )
260 #define DOCINFOW DOCINFO
261 #define DOCINFOA DOCINFO
262 #endif
263 #endif
264
265 #ifdef _UNICODE
266 inline int StartDoc(HDC h, CONST DOCINFOW* info)
267 {
268 return StartDocW(h, (DOCINFOW*) info);
269 }
270 #else
271 inline int StartDoc(HDC h, CONST DOCINFOA* info)
272 {
273 return StartDocA(h, (DOCINFOA*) info);
274 }
275 #endif
276 #endif
277
278 // GetObject
279
280 #ifdef GetObject
281 #undef GetObject
282 inline int GetObject(HGDIOBJ h, int i, LPVOID buffer)
283 {
284 #ifdef _UNICODE
285 return GetObjectW(h, i, buffer);
286 #else
287 return GetObjectA(h, i, buffer);
288 #endif
289 }
290 #endif
291
292 // GetMessage
293
294 #ifdef GetMessage
295 #undef GetMessage
296 inline int GetMessage(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax)
297 {
298 #ifdef _UNICODE
299 return GetMessageW(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax);
300 #else
301 return GetMessageA(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax);
302 #endif
303 }
304 #endif
305
306 // LoadIcon
307 #ifdef LoadIcon
308 #undef LoadIcon
309 inline HICON LoadIcon(HINSTANCE hInstance, LPCTSTR lpIconName)
310 {
311 #ifdef _UNICODE
312 return LoadIconW(hInstance, lpIconName);
313 #else // ANSI
314 return LoadIconA(hInstance, lpIconName);
315 #endif // Unicode/ANSI
316 }
317 #endif // LoadIcon
318
319 // LoadBitmap
320 #ifdef LoadBitmap
321 #undef LoadBitmap
322 inline HBITMAP LoadBitmap(HINSTANCE hInstance, LPCTSTR lpBitmapName)
323 {
324 #ifdef _UNICODE
325 return LoadBitmapW(hInstance, lpBitmapName);
326 #else // ANSI
327 return LoadBitmapA(hInstance, lpBitmapName);
328 #endif // Unicode/ANSI
329 }
330 #endif // LoadBitmap
331
332 // LoadLibrary
333
334 #ifdef LoadLibrary
335 #undef LoadLibrary
336 #ifdef _UNICODE
337 inline HINSTANCE LoadLibrary(LPCWSTR lpLibFileName)
338 {
339 return LoadLibraryW(lpLibFileName);
340 }
341 #else
342 inline HINSTANCE LoadLibrary(LPCSTR lpLibFileName)
343 {
344 return LoadLibraryA(lpLibFileName);
345 }
346 #endif
347 #endif
348
349 // FindResource
350 #ifdef FindResource
351 #undef FindResource
352 #ifdef _UNICODE
353 inline HRSRC FindResource(HMODULE hModule, LPCWSTR lpName, LPCWSTR lpType)
354 {
355 return FindResourceW(hModule, lpName, lpType);
356 }
357 #else
358 inline HRSRC FindResource(HMODULE hModule, LPCSTR lpName, LPCSTR lpType)
359 {
360 return FindResourceA(hModule, lpName, lpType);
361 }
362 #endif
363 #endif
364
365 // IsMaximized
366
367 #ifdef IsMaximized
368 #undef IsMaximized
369 inline BOOL IsMaximized(HWND WXUNUSED_IN_WINCE(hwnd))
370 {
371 #ifdef __WXWINCE__
372 return FALSE;
373 #else
374 return IsZoomed(hwnd);
375 #endif
376 }
377 #endif
378
379 // GetFirstChild
380
381 #ifdef GetFirstChild
382 #undef GetFirstChild
383 inline HWND GetFirstChild(HWND WXUNUSED_IN_WINCE(hwnd))
384 {
385 #ifdef __WXWINCE__
386 return 0;
387 #else
388 return GetTopWindow(hwnd);
389 #endif
390 }
391 #endif
392
393 // GetFirstSibling
394
395 #ifdef GetFirstSibling
396 #undef GetFirstSibling
397 inline HWND GetFirstSibling(HWND hwnd)
398 {
399 return GetWindow(hwnd,GW_HWNDFIRST);
400 }
401 #endif
402
403 // GetLastSibling
404
405 #ifdef GetLastSibling
406 #undef GetLastSibling
407 inline HWND GetLastSibling(HWND hwnd)
408 {
409 return GetWindow(hwnd,GW_HWNDLAST);
410 }
411 #endif
412
413 // GetPrevSibling
414
415 #ifdef GetPrevSibling
416 #undef GetPrevSibling
417 inline HWND GetPrevSibling(HWND hwnd)
418 {
419 return GetWindow(hwnd,GW_HWNDPREV);
420 }
421 #endif
422
423 // GetNextSibling
424
425 #ifdef GetNextSibling
426 #undef GetNextSibling
427 inline HWND GetNextSibling(HWND hwnd)
428 {
429 return GetWindow(hwnd,GW_HWNDNEXT);
430 }
431 #endif
432
433 // For WINE
434
435 #if defined(GetWindowStyle)
436 #undef GetWindowStyle
437 #endif
438
439 // For ming and cygwin
440
441 // GetFirstChild
442 #ifdef GetFirstChild
443 #undef GetFirstChild
444 inline HWND GetFirstChild(HWND h)
445 {
446 return GetTopWindow(h);
447 }
448 #endif
449
450
451 // GetNextSibling
452 #ifdef GetNextSibling
453 #undef GetNextSibling
454 inline HWND GetNextSibling(HWND h)
455 {
456 return GetWindow(h, GW_HWNDNEXT);
457 }
458 #endif
459
460
461 #ifdef Yield
462 #undef Yield
463 #endif
464
465
466 #if defined(__WXWINCE__) && defined(DrawIcon) //#ifdef DrawIcon
467 #undef DrawIcon
468 inline BOOL DrawIcon(HDC hdc, int x, int y, HICON hicon)
469 {
470 return DrawIconEx(hdc,x,y,hicon,0,0,0,NULL, DI_NORMAL) ;
471 }
472 #endif
473
474
475 // GetWindowProc
476 //ifdef GetWindowProc
477 // #undef GetWindowProc
478 //endif
479 //ifdef GetNextChild
480 // #undef GetNextChild
481 //endif
482
483 // #endif // _WX_WINUNDEF_H_
484