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
);
255 #if defined( __GNUG__ ) && !wxCHECK_W32API_VERSION( 0, 5 )
256 #define DOCINFOW DOCINFO
257 #define DOCINFOA DOCINFO
260 inline int StartDoc(HDC h
, CONST DOCINFOW
* info
)
262 return StartDocW(h
, (DOCINFOW
*) info
);
265 inline int StartDoc(HDC h
, CONST DOCINFOA
* info
)
267 return StartDocA(h
, (DOCINFOA
*) info
);
276 inline int GetObject(HGDIOBJ h
, int i
, LPVOID buffer
)
279 return GetObjectW(h
, i
, buffer
);
281 return GetObjectA(h
, i
, buffer
);
290 inline int GetMessage(LPMSG lpMsg
, HWND hWnd
, UINT wMsgFilterMin
, UINT wMsgFilterMax
)
293 return GetMessageW(lpMsg
, hWnd
, wMsgFilterMin
, wMsgFilterMax
);
295 return GetMessageA(lpMsg
, hWnd
, wMsgFilterMin
, wMsgFilterMax
);
303 inline HICON
LoadIcon(HINSTANCE hInstance
, LPCTSTR lpIconName
)
306 return LoadIconW(hInstance
, lpIconName
);
308 return LoadIconA(hInstance
, lpIconName
);
309 #endif // Unicode/ANSI
316 inline HBITMAP
LoadBitmap(HINSTANCE hInstance
, LPCTSTR lpBitmapName
)
319 return LoadBitmapW(hInstance
, lpBitmapName
);
321 return LoadBitmapA(hInstance
, lpBitmapName
);
322 #endif // Unicode/ANSI
331 inline HINSTANCE
LoadLibrary(LPCWSTR lpLibFileName
)
333 return LoadLibraryW(lpLibFileName
);
336 inline HINSTANCE
LoadLibrary(LPCSTR lpLibFileName
)
338 return LoadLibraryA(lpLibFileName
);
347 inline HRSRC
FindResource(HMODULE hModule
, LPCWSTR lpName
, LPCWSTR lpType
)
349 return FindResourceW(hModule
, lpName
, lpType
);
352 inline HRSRC
FindResource(HMODULE hModule
, LPCSTR lpName
, LPCSTR lpType
)
354 return FindResourceA(hModule
, lpName
, lpType
);
363 inline BOOL
IsMaximized(HWND
WXUNUSED_IN_WINCE(hwnd
))
368 return IsZoomed(hwnd
);
377 inline HWND
GetFirstChild(HWND
WXUNUSED_IN_WINCE(hwnd
))
382 return GetTopWindow(hwnd
);
389 #ifdef GetFirstSibling
390 #undef GetFirstSibling
391 inline HWND
GetFirstSibling(HWND hwnd
)
393 return GetWindow(hwnd
,GW_HWNDFIRST
);
399 #ifdef GetLastSibling
400 #undef GetLastSibling
401 inline HWND
GetLastSibling(HWND hwnd
)
403 return GetWindow(hwnd
,GW_HWNDLAST
);
409 #ifdef GetPrevSibling
410 #undef GetPrevSibling
411 inline HWND
GetPrevSibling(HWND hwnd
)
413 return GetWindow(hwnd
,GW_HWNDPREV
);
419 #ifdef GetNextSibling
420 #undef GetNextSibling
421 inline HWND
GetNextSibling(HWND hwnd
)
423 return GetWindow(hwnd
,GW_HWNDNEXT
);
429 #if defined(GetWindowStyle)
430 #undef GetWindowStyle
433 // For ming and cygwin
438 inline HWND
GetFirstChild(HWND h
)
440 return GetTopWindow(h
);
446 #ifdef GetNextSibling
447 #undef GetNextSibling
448 inline HWND
GetNextSibling(HWND h
)
450 return GetWindow(h
, GW_HWNDNEXT
);
460 #if defined(__WXWINCE__) && defined(DrawIcon) //#ifdef DrawIcon
462 inline BOOL
DrawIcon(HDC hdc
, int x
, int y
, HICON hicon
)
464 return DrawIconEx(hdc
,x
,y
,hicon
,0,0,0,NULL
, DI_NORMAL
) ;
470 //ifdef GetWindowProc
471 // #undef GetWindowProc
474 // #undef GetNextChild
477 // #endif // _WX_WINUNDEF_H_