1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: undefine the common symbols #define'd by <windows.h>
4 // Author: Vadim Zeitlin
8 // Copyright: (c) wxWidgets team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
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
15 #ifndef _WX_WINUNDEF_H_
16 #define _WX_WINUNDEF_H_
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.
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 // ----------------------------------------------------------------------------
30 #if defined(CreateDialog)
33 inline HWND
CreateDialog(HINSTANCE hInstance
,
39 return CreateDialogW(hInstance
, pTemplate
, hwndParent
, pDlgProc
);
41 return CreateDialogA(hInstance
, pTemplate
, hwndParent
, pDlgProc
);
51 inline HFONT
CreateFont(int height
,
67 return CreateFontW(height
, width
, escapement
, orientation
,
68 weight
, italic
, underline
, strikeout
, charset
,
69 outprecision
, clipprecision
, quality
,
72 return CreateFontA(height
, width
, escapement
, orientation
,
73 weight
, italic
, underline
, strikeout
, charset
,
74 outprecision
, clipprecision
, quality
,
82 #if defined(CreateWindow)
85 inline HWND
CreateWindow(LPCTSTR lpClassName
,
88 int x
, int y
, int w
, int h
,
95 return CreateWindowW(lpClassName
, lpWndClass
, dwStyle
, x
, y
, w
, h
,
96 hWndParent
, hMenu
, hInstance
, lpParam
);
98 return CreateWindowA(lpClassName
, lpWndClass
, dwStyle
, x
, y
, w
, h
,
99 hWndParent
, hMenu
, hInstance
, lpParam
);
109 inline HMENU
LoadMenu(HINSTANCE instance
, LPCTSTR name
)
112 return LoadMenuW(instance
, name
);
114 return LoadMenuA(instance
, name
);
124 inline HWND APIENTRY
FindText(LPFINDREPLACE lpfindreplace
)
127 return FindTextW(lpfindreplace
);
129 return FindTextA(lpfindreplace
);
138 inline BOOL
GetCharWidth(HDC dc
, UINT first
, UINT last
, LPINT buffer
)
141 return GetCharWidthW(dc
, first
, last
, buffer
);
143 return GetCharWidthA(dc
, first
, last
, buffer
);
153 inline HWND
FindWindow(LPCWSTR classname
, LPCWSTR windowname
)
155 return FindWindowW(classname
, windowname
);
158 inline HWND
FindWindow(LPCSTR classname
, LPCSTR windowname
)
160 return FindWindowA(classname
, windowname
);
170 inline BOOL
PlaySound(LPCWSTR pszSound
, HMODULE hMod
, DWORD fdwSound
)
172 return PlaySoundW(pszSound
, hMod
, fdwSound
);
175 inline BOOL
PlaySound(LPCSTR pszSound
, HMODULE hMod
, DWORD fdwSound
)
177 return PlaySoundA(pszSound
, hMod
, fdwSound
);
187 inline int GetClassName(HWND h
, LPWSTR classname
, int maxcount
)
189 return GetClassNameW(h
, classname
, maxcount
);
192 inline int GetClassName(HWND h
, LPSTR classname
, int maxcount
)
194 return GetClassNameA(h
, classname
, maxcount
);
204 inline BOOL
GetClassInfo(HINSTANCE h
, LPCWSTR name
, LPWNDCLASSW winclass
)
206 return GetClassInfoW(h
, name
, winclass
);
209 inline BOOL
GetClassInfo(HINSTANCE h
, LPCSTR name
, LPWNDCLASSA winclass
)
211 return GetClassInfoA(h
, name
, winclass
);
218 #ifdef LoadAccelerators
219 #undef LoadAccelerators
221 inline HACCEL
LoadAccelerators(HINSTANCE h
, LPCWSTR name
)
223 return LoadAcceleratorsW(h
, name
);
226 inline HACCEL
LoadAccelerators(HINSTANCE h
, LPCSTR name
)
228 return LoadAcceleratorsA(h
, name
);
238 inline int DrawText(HDC h
, LPCWSTR str
, int count
, LPRECT rect
, UINT format
)
240 return DrawTextW(h
, str
, count
, rect
, format
);
243 inline int DrawText(HDC h
, LPCSTR str
, int count
, LPRECT rect
, UINT format
)
245 return DrawTextA(h
, str
, count
, rect
, format
);
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
266 inline int StartDoc(HDC h
, CONST DOCINFOW
* info
)
268 return StartDocW(h
, (DOCINFOW
*) info
);
271 inline int StartDoc(HDC h
, CONST DOCINFOA
* info
)
273 return StartDocA(h
, (DOCINFOA
*) info
);
282 inline int GetObject(HGDIOBJ h
, int i
, LPVOID buffer
)
285 return GetObjectW(h
, i
, buffer
);
287 return GetObjectA(h
, i
, buffer
);
296 inline int GetMessage(LPMSG lpMsg
, HWND hWnd
, UINT wMsgFilterMin
, UINT wMsgFilterMax
)
299 return GetMessageW(lpMsg
, hWnd
, wMsgFilterMin
, wMsgFilterMax
);
301 return GetMessageA(lpMsg
, hWnd
, wMsgFilterMin
, wMsgFilterMax
);
309 inline HICON
LoadIcon(HINSTANCE hInstance
, LPCTSTR lpIconName
)
312 return LoadIconW(hInstance
, lpIconName
);
314 return LoadIconA(hInstance
, lpIconName
);
315 #endif // Unicode/ANSI
322 inline HBITMAP
LoadBitmap(HINSTANCE hInstance
, LPCTSTR lpBitmapName
)
325 return LoadBitmapW(hInstance
, lpBitmapName
);
327 return LoadBitmapA(hInstance
, lpBitmapName
);
328 #endif // Unicode/ANSI
337 inline HINSTANCE
LoadLibrary(LPCWSTR lpLibFileName
)
339 return LoadLibraryW(lpLibFileName
);
342 inline HINSTANCE
LoadLibrary(LPCSTR lpLibFileName
)
344 return LoadLibraryA(lpLibFileName
);
353 inline HRSRC
FindResource(HMODULE hModule
, LPCWSTR lpName
, LPCWSTR lpType
)
355 return FindResourceW(hModule
, lpName
, lpType
);
358 inline HRSRC
FindResource(HMODULE hModule
, LPCSTR lpName
, LPCSTR lpType
)
360 return FindResourceA(hModule
, lpName
, lpType
);
369 inline BOOL
IsMaximized(HWND
WXUNUSED_IN_WINCE(hwnd
))
374 return IsZoomed(hwnd
);
383 inline HWND
GetFirstChild(HWND
WXUNUSED_IN_WINCE(hwnd
))
388 return GetTopWindow(hwnd
);
395 #ifdef GetFirstSibling
396 #undef GetFirstSibling
397 inline HWND
GetFirstSibling(HWND hwnd
)
399 return GetWindow(hwnd
,GW_HWNDFIRST
);
405 #ifdef GetLastSibling
406 #undef GetLastSibling
407 inline HWND
GetLastSibling(HWND hwnd
)
409 return GetWindow(hwnd
,GW_HWNDLAST
);
415 #ifdef GetPrevSibling
416 #undef GetPrevSibling
417 inline HWND
GetPrevSibling(HWND hwnd
)
419 return GetWindow(hwnd
,GW_HWNDPREV
);
425 #ifdef GetNextSibling
426 #undef GetNextSibling
427 inline HWND
GetNextSibling(HWND hwnd
)
429 return GetWindow(hwnd
,GW_HWNDNEXT
);
435 #if defined(GetWindowStyle)
436 #undef GetWindowStyle
439 // For ming and cygwin
444 inline HWND
GetFirstChild(HWND h
)
446 return GetTopWindow(h
);
452 #ifdef GetNextSibling
453 #undef GetNextSibling
454 inline HWND
GetNextSibling(HWND h
)
456 return GetWindow(h
, GW_HWNDNEXT
);
466 #if defined(__WXWINCE__) && defined(DrawIcon) //#ifdef DrawIcon
468 inline BOOL
DrawIcon(HDC hdc
, int x
, int y
, HICON hicon
)
470 return DrawIconEx(hdc
,x
,y
,hicon
,0,0,0,NULL
, DI_NORMAL
) ;
476 //ifdef GetWindowProc
477 // #undef GetWindowProc
480 // #undef GetNextChild
483 // #endif // _WX_WINUNDEF_H_