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
);
48 #if defined(CreateWindow)
51 inline HWND
CreateWindow(LPCTSTR lpClassName
,
54 int x
, int y
, int w
, int h
,
61 return CreateWindowW(lpClassName
, lpWndClass
, dwStyle
, x
, y
, w
, h
,
62 hWndParent
, hMenu
, hInstance
, lpParam
);
64 return CreateWindowA(lpClassName
, lpWndClass
, dwStyle
, x
, y
, w
, h
,
65 hWndParent
, hMenu
, hInstance
, lpParam
);
75 inline HMENU
LoadMenu(HINSTANCE instance
, LPCTSTR name
)
78 return LoadMenuW(instance
, name
);
80 return LoadMenuA(instance
, name
);
90 inline HWND APIENTRY
FindText(LPFINDREPLACE lpfindreplace
)
93 return FindTextW(lpfindreplace
);
95 return FindTextA(lpfindreplace
);
104 inline BOOL
GetCharWidth(HDC dc
, UINT first
, UINT last
, LPINT buffer
)
107 return GetCharWidthW(dc
, first
, last
, buffer
);
109 return GetCharWidthA(dc
, first
, last
, buffer
);
119 inline HWND
FindWindow(LPCWSTR classname
, LPCWSTR windowname
)
121 return FindWindowW(classname
, windowname
);
124 inline HWND
FindWindow(LPCSTR classname
, LPCSTR windowname
)
126 return FindWindowA(classname
, windowname
);
136 inline BOOL
PlaySound(LPCWSTR pszSound
, HMODULE hMod
, DWORD fdwSound
)
138 return PlaySoundW(pszSound
, hMod
, fdwSound
);
141 inline BOOL
PlaySound(LPCSTR pszSound
, HMODULE hMod
, DWORD fdwSound
)
143 return PlaySoundA(pszSound
, hMod
, fdwSound
);
153 inline int GetClassName(HWND h
, LPWSTR classname
, int maxcount
)
155 return GetClassNameW(h
, classname
, maxcount
);
158 inline int GetClassName(HWND h
, LPSTR classname
, int maxcount
)
160 return GetClassNameA(h
, classname
, maxcount
);
170 inline BOOL
GetClassInfo(HINSTANCE h
, LPCWSTR name
, LPWNDCLASSW winclass
)
172 return GetClassInfoW(h
, name
, winclass
);
175 inline BOOL
GetClassInfo(HINSTANCE h
, LPCSTR name
, LPWNDCLASSA winclass
)
177 return GetClassInfoA(h
, name
, winclass
);
184 #ifdef LoadAccelerators
185 #undef LoadAccelerators
187 inline HACCEL
LoadAccelerators(HINSTANCE h
, LPCWSTR name
)
189 return LoadAcceleratorsW(h
, name
);
192 inline HACCEL
LoadAccelerators(HINSTANCE h
, LPCSTR name
)
194 return LoadAcceleratorsA(h
, name
);
204 inline int DrawText(HDC h
, LPCWSTR str
, int count
, LPRECT rect
, UINT format
)
206 return DrawTextW(h
, str
, count
, rect
, format
);
209 inline int DrawText(HDC h
, LPCSTR str
, int count
, LPRECT rect
, UINT format
)
211 return DrawTextA(h
, str
, count
, rect
, format
);
218 When this file is included, sometimes the wxCHECK_W32API_VERSION macro
219 is undefined. With for example CodeWarrior this gives problems with
221 #if 0 && wxCHECK_W32API_VERSION( 0, 5 )
222 Because CodeWarrior does macro expansion before test evaluation.
223 We define wxCHECK_W32API_VERSION here if it's undefined.
225 #if !defined(__GNUG__) && !defined(wxCHECK_W32API_VERSION)
226 #define wxCHECK_W32API_VERSION(maj, min) (0)
233 #if defined( __GNUG__ ) && !wxCHECK_W32API_VERSION( 0, 5 )
234 #define DOCINFOW DOCINFO
235 #define DOCINFOA DOCINFO
238 inline int StartDoc(HDC h
, CONST DOCINFOW
* info
)
240 return StartDocW(h
, (DOCINFOW
*) info
);
243 inline int StartDoc(HDC h
, CONST DOCINFOA
* info
)
245 return StartDocA(h
, (DOCINFOA
*) info
);
254 inline int GetObject(HGDIOBJ h
, int i
, LPVOID buffer
)
257 return GetObjectW(h
, i
, buffer
);
259 return GetObjectA(h
, i
, buffer
);
268 inline int GetMessage(LPMSG lpMsg
, HWND hWnd
, UINT wMsgFilterMin
, UINT wMsgFilterMax
)
271 return GetMessageW(lpMsg
, hWnd
, wMsgFilterMin
, wMsgFilterMax
);
273 return GetMessageA(lpMsg
, hWnd
, wMsgFilterMin
, wMsgFilterMax
);
281 inline HICON
LoadIcon(HINSTANCE hInstance
, LPCTSTR lpIconName
)
284 return LoadIconW(hInstance
, lpIconName
);
286 return LoadIconA(hInstance
, lpIconName
);
287 #endif // Unicode/ANSI
294 inline HBITMAP
LoadBitmap(HINSTANCE hInstance
, LPCTSTR lpBitmapName
)
297 return LoadBitmapW(hInstance
, lpBitmapName
);
299 return LoadBitmapA(hInstance
, lpBitmapName
);
300 #endif // Unicode/ANSI
309 inline HINSTANCE
LoadLibrary(LPCWSTR lpLibFileName
)
311 return LoadLibraryW(lpLibFileName
);
314 inline HINSTANCE
LoadLibrary(LPCSTR lpLibFileName
)
316 return LoadLibraryA(lpLibFileName
);
325 inline HRSRC
FindResource(HMODULE hModule
, LPCWSTR lpName
, LPCWSTR lpType
)
327 return FindResourceW(hModule
, lpName
, lpType
);
330 inline HRSRC
FindResource(HMODULE hModule
, LPCSTR lpName
, LPCSTR lpType
)
332 return FindResourceA(hModule
, lpName
, lpType
);
341 inline BOOL
IsMaximized(HWND
WXUNUSED_IN_WINCE(hwnd
))
346 return IsZoomed(hwnd
);
355 inline HWND
GetFirstChild(HWND
WXUNUSED_IN_WINCE(hwnd
))
360 return GetTopWindow(hwnd
);
367 #ifdef GetPrevSibling
368 #undef GetPrevSibling
369 inline HWND
GetPrevSibling(HWND hwnd
)
371 return GetWindow(hwnd
,GW_HWNDPREV
);
377 #ifdef GetNextSibling
378 #undef GetNextSibling
379 inline HWND
GetNextSibling(HWND hwnd
)
381 return GetWindow(hwnd
,GW_HWNDNEXT
);
387 #if defined(GetWindowStyle)
388 #undef GetWindowStyle
391 // For ming and cygwin
396 inline HWND
GetFirstChild(HWND h
)
398 return GetTopWindow(h
);
404 #ifdef GetNextSibling
405 #undef GetNextSibling
406 inline HWND
GetNextSibling(HWND h
)
408 return GetWindow(h
, GW_HWNDNEXT
);
418 #if defined(__WXWINCE__) && defined(DrawIcon) //#ifdef DrawIcon
420 inline BOOL
DrawIcon(HDC hdc
, int x
, int y
, HICON hicon
)
422 return DrawIconEx(hdc
,x
,y
,hicon
,0,0,0,NULL
, DI_NORMAL
) ;
428 //ifdef GetWindowProc
429 // #undef GetWindowProc
432 // #undef GetNextChild
435 // #endif // _WX_WINUNDEF_H_