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 HMENU
LoadMenu(HINSTANCE instance
, LPCTSTR name
)
54 return LoadMenuW(instance
, name
);
56 return LoadMenuA(instance
, name
);
66 inline HWND APIENTRY
FindText(LPFINDREPLACE lpfindreplace
)
69 return FindTextW(lpfindreplace
);
71 return FindTextA(lpfindreplace
);
80 inline BOOL
GetCharWidth(HDC dc
, UINT first
, UINT last
, LPINT buffer
)
83 return GetCharWidthW(dc
, first
, last
, buffer
);
85 return GetCharWidthA(dc
, first
, last
, buffer
);
95 inline HWND
FindWindow(LPCWSTR classname
, LPCWSTR windowname
)
97 return FindWindowW(classname
, windowname
);
100 inline HWND
FindWindow(LPCSTR classname
, LPCSTR windowname
)
102 return FindWindowA(classname
, windowname
);
112 inline BOOL
PlaySound(LPCWSTR pszSound
, HMODULE hMod
, DWORD fdwSound
)
114 return PlaySoundW(pszSound
, hMod
, fdwSound
);
117 inline BOOL
PlaySound(LPCSTR pszSound
, HMODULE hMod
, DWORD fdwSound
)
119 return PlaySoundA(pszSound
, hMod
, fdwSound
);
129 inline int GetClassName(HWND h
, LPWSTR classname
, int maxcount
)
131 return GetClassNameW(h
, classname
, maxcount
);
134 inline int GetClassName(HWND h
, LPSTR classname
, int maxcount
)
136 return GetClassNameA(h
, classname
, maxcount
);
146 inline BOOL
GetClassInfo(HINSTANCE h
, LPCWSTR name
, LPWNDCLASSW winclass
)
148 return GetClassInfoW(h
, name
, winclass
);
151 inline BOOL
GetClassInfo(HINSTANCE h
, LPCSTR name
, LPWNDCLASSA winclass
)
153 return GetClassInfoA(h
, name
, winclass
);
160 #ifdef LoadAccelerators
161 #undef LoadAccelerators
163 inline HACCEL
LoadAccelerators(HINSTANCE h
, LPCWSTR name
)
165 return LoadAcceleratorsW(h
, name
);
168 inline HACCEL
LoadAccelerators(HINSTANCE h
, LPCSTR name
)
170 return LoadAcceleratorsA(h
, name
);
180 inline int DrawText(HDC h
, LPCWSTR str
, int count
, LPRECT rect
, UINT format
)
182 return DrawTextW(h
, str
, count
, rect
, format
);
185 inline int DrawText(HDC h
, LPCSTR str
, int count
, LPRECT rect
, UINT format
)
187 return DrawTextA(h
, str
, count
, rect
, format
);
194 When this file is included, sometimes the wxCHECK_W32API_VERSION macro
195 is undefined. With for example CodeWarrior this gives problems with
197 #if 0 && wxCHECK_W32API_VERSION( 0, 5 )
198 Because CodeWarrior does macro expansion before test evaluation.
199 We define wxCHECK_W32API_VERSION here if it's undefined.
201 #if !defined(__GNUG__) && !defined(wxCHECK_W32API_VERSION)
202 #define wxCHECK_W32API_VERSION(maj, min) (0)
209 #if defined( __GNUG__ ) && !wxCHECK_W32API_VERSION( 0, 5 )
210 #define DOCINFOW DOCINFO
211 #define DOCINFOA DOCINFO
214 inline int StartDoc(HDC h
, CONST DOCINFOW
* info
)
216 return StartDocW(h
, (DOCINFOW
*) info
);
219 inline int StartDoc(HDC h
, CONST DOCINFOA
* info
)
221 return StartDocA(h
, (DOCINFOA
*) info
);
230 inline int GetObject(HGDIOBJ h
, int i
, LPVOID buffer
)
233 return GetObjectW(h
, i
, buffer
);
235 return GetObjectA(h
, i
, buffer
);
244 inline int GetMessage(LPMSG lpMsg
, HWND hWnd
, UINT wMsgFilterMin
, UINT wMsgFilterMax
)
247 return GetMessageW(lpMsg
, hWnd
, wMsgFilterMin
, wMsgFilterMax
);
249 return GetMessageA(lpMsg
, hWnd
, wMsgFilterMin
, wMsgFilterMax
);
257 inline HICON
LoadIcon(HINSTANCE hInstance
, LPCTSTR lpIconName
)
260 return LoadIconW(hInstance
, lpIconName
);
262 return LoadIconA(hInstance
, lpIconName
);
263 #endif // Unicode/ANSI
270 inline HBITMAP
LoadBitmap(HINSTANCE hInstance
, LPCTSTR lpBitmapName
)
273 return LoadBitmapW(hInstance
, lpBitmapName
);
275 return LoadBitmapA(hInstance
, lpBitmapName
);
276 #endif // Unicode/ANSI
285 inline HINSTANCE
LoadLibrary(LPCWSTR lpLibFileName
)
287 return LoadLibraryW(lpLibFileName
);
290 inline HINSTANCE
LoadLibrary(LPCSTR lpLibFileName
)
292 return LoadLibraryA(lpLibFileName
);
301 inline HRSRC
FindResource(HMODULE hModule
, LPCWSTR lpName
, LPCWSTR lpType
)
303 return FindResourceW(hModule
, lpName
, lpType
);
306 inline HRSRC
FindResource(HMODULE hModule
, LPCSTR lpName
, LPCSTR lpType
)
308 return FindResourceA(hModule
, lpName
, lpType
);
317 inline BOOL
IsMaximized(HWND hwnd
)
322 return IsZoomed(hwnd
);
331 inline HWND
GetFirstChild(HWND hwnd
)
336 return GetTopWindow(hwnd
);
343 #ifdef GetPrevSibling
344 #undef GetPrevSibling
345 inline HWND
GetPrevSibling(HWND hwnd
)
347 return GetWindow(hwnd
,GW_HWNDPREV
);
353 #ifdef GetNextSibling
354 #undef GetNextSibling
355 inline HWND
GetNextSibling(HWND hwnd
)
357 return GetWindow(hwnd
,GW_HWNDNEXT
);
363 #if defined(GetWindowStyle)
364 #undef GetWindowStyle
367 // For ming and cygwin
372 inline HWND
GetFirstChild(HWND h
)
374 return GetTopWindow(h
);
380 #ifdef GetNextSibling
381 #undef GetNextSibling
382 inline HWND
GetNextSibling(HWND h
)
384 return GetWindow(h
, GW_HWNDNEXT
);
394 #if defined(__WXWINCE__) && defined(DrawIcon) //#ifdef DrawIcon
396 inline BOOL
DrawIcon(HDC hdc
, int x
, int y
, HICON hicon
)
398 return DrawIconEx(hdc
,x
,y
,hicon
,0,0,0,NULL
, DI_NORMAL
) ;
404 //ifdef GetWindowProc
405 // #undef GetWindowProc
408 // #undef GetNextChild
411 // #endif // _WX_WINUNDEF_H_