1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: undefine the common symbols #define'd by <windows.h>
4 // Author: Vadim Zeitlin
8 // Copyright: (c) wxWindows 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 //#ifdef(CreateDialog)
31 #if !defined(__WXWINCE__) && defined(CreateDialog)
34 inline HWND
CreateDialog(HINSTANCE hInstance
,
40 return CreateDialogW(hInstance
, pTemplate
, hwndParent
, pDlgProc
);
42 return CreateDialogA(hInstance
, pTemplate
, hwndParent
, pDlgProc
);
52 inline HMENU
LoadMenu(HINSTANCE instance
, LPCTSTR name
)
55 return LoadMenuW(instance
, name
);
57 return LoadMenuA(instance
, name
);
67 inline HWND APIENTRY
FindText(LPFINDREPLACE lpfindreplace
)
70 return FindTextW(lpfindreplace
);
72 return FindTextA(lpfindreplace
);
81 inline BOOL
GetCharWidth(HDC dc
, UINT first
, UINT last
, LPINT buffer
)
84 return GetCharWidthW(dc
, first
, last
, buffer
);
86 return GetCharWidthA(dc
, first
, last
, buffer
);
96 inline HWND
FindWindow(LPCWSTR classname
, LPCWSTR windowname
)
98 return FindWindowW(classname
, windowname
);
101 inline HWND
FindWindow(LPCSTR classname
, LPCSTR windowname
)
103 return FindWindowA(classname
, windowname
);
113 inline BOOL
PlaySound(LPCWSTR pszSound
, HMODULE hMod
, DWORD fdwSound
)
115 return PlaySoundW(pszSound
, hMod
, fdwSound
);
118 inline BOOL
PlaySound(LPCSTR pszSound
, HMODULE hMod
, DWORD fdwSound
)
120 return PlaySoundA(pszSound
, hMod
, fdwSound
);
130 inline int GetClassName(HWND h
, LPWSTR classname
, int maxcount
)
132 return GetClassNameW(h
, classname
, maxcount
);
135 inline int GetClassName(HWND h
, LPSTR classname
, int maxcount
)
137 return GetClassNameA(h
, classname
, maxcount
);
147 inline BOOL
GetClassInfo(HINSTANCE h
, LPCWSTR name
, LPWNDCLASSW winclass
)
149 return GetClassInfoW(h
, name
, winclass
);
152 inline BOOL
GetClassInfo(HINSTANCE h
, LPCSTR name
, LPWNDCLASSA winclass
)
154 return GetClassInfoA(h
, name
, winclass
);
161 #ifdef LoadAccelerators
162 #undef LoadAccelerators
164 inline HACCEL
LoadAccelerators(HINSTANCE h
, LPCWSTR name
)
166 return LoadAcceleratorsW(h
, name
);
169 inline HACCEL
LoadAccelerators(HINSTANCE h
, LPCSTR name
)
171 return LoadAcceleratorsA(h
, name
);
181 inline int DrawText(HDC h
, LPCWSTR str
, int count
, LPRECT rect
, UINT format
)
183 return DrawTextW(h
, str
, count
, rect
, format
);
186 inline int DrawText(HDC h
, LPCSTR str
, int count
, LPRECT rect
, UINT format
)
188 return DrawTextA(h
, str
, count
, rect
, format
);
195 When this file is included, sometimes the wxCHECK_W32API_VERSION macro
196 is undefined. With for example CodeWarrior this gives problems with
198 #if 0 && wxCHECK_W32API_VERSION( 0, 5 )
199 Because CodeWarrior does macro expansion before test evaluation.
200 We define wxCHECK_W32API_VERSION here if it's undefined.
202 #if !defined(__GNUG__) && !defined(wxCHECK_W32API_VERSION)
203 #define wxCHECK_W32API_VERSION(maj, min) (0)
210 #if defined( __GNUG__ ) && !wxCHECK_W32API_VERSION( 0, 5 )
211 #define DOCINFOW DOCINFO
212 #define DOCINFOA DOCINFO
215 inline int StartDoc(HDC h
, CONST DOCINFOW
* info
)
217 return StartDocW(h
, (DOCINFOW
*) info
);
220 inline int StartDoc(HDC h
, CONST DOCINFOA
* info
)
222 return StartDocA(h
, (DOCINFOA
*) info
);
231 inline int GetObject(HGDIOBJ h
, int i
, LPVOID buffer
)
234 return GetObjectW(h
, i
, buffer
);
236 return GetObjectA(h
, i
, buffer
);
245 inline int GetMessage(LPMSG lpMsg
, HWND hWnd
, UINT wMsgFilterMin
, UINT wMsgFilterMax
)
248 return GetMessageW(lpMsg
, hWnd
, wMsgFilterMin
, wMsgFilterMax
);
250 return GetMessageA(lpMsg
, hWnd
, wMsgFilterMin
, wMsgFilterMax
);
258 inline HICON
LoadIcon(HINSTANCE hInstance
, LPCTSTR lpIconName
)
261 return LoadIconW(hInstance
, lpIconName
);
263 return LoadIconA(hInstance
, lpIconName
);
264 #endif // Unicode/ANSI
274 inline HINSTANCE
LoadLibrary(LPCWSTR lpLibFileName
)
276 return LoadLibraryW(lpLibFileName
);
279 inline HINSTANCE
LoadLibrary(LPCSTR lpLibFileName
)
281 return LoadLibraryA(lpLibFileName
);
290 inline HRSRC
FindResource(HMODULE hModule
, LPCWSTR lpName
, LPCWSTR lpType
)
292 return FindResourceW(hModule
, lpName
, lpType
);
295 inline HRSRC
FindResource(HMODULE hModule
, LPCSTR lpName
, LPCSTR lpType
)
297 return FindResourceA(hModule
, lpName
, lpType
);
306 inline BOOL
IsMaximized(HWND hwnd
)
308 return IsZoomed(hwnd
);
316 inline HWND
GetFirstChild(HWND hwnd
)
318 return GetTopWindow(hwnd
);
324 #ifdef GetPrevSibling
325 #undef GetPrevSibling
326 inline HWND
GetPrevSibling(HWND hwnd
)
328 return GetWindow(hwnd
,GW_HWNDPREV
);
334 #ifdef GetNextSibling
335 #undef GetNextSibling
336 inline HWND
GetNextSibling(HWND hwnd
)
338 return GetWindow(hwnd
,GW_HWNDNEXT
);
344 #if defined(GetWindowStyle)
345 #undef GetWindowStyle
348 // For ming and cygwin
353 inline HWND
GetFirstChild(HWND h
)
355 return GetTopWindow(h
);
361 #ifdef GetNextSibling
362 #undef GetNextSibling
363 inline HWND
GetNextSibling(HWND h
)
365 return GetWindow(h
, GW_HWNDNEXT
);
375 #if defined(__WXWINCE__) && defined(DrawIcon) //#ifdef DrawIcon
377 inline BOOL
DrawIcon(HDC hdc
, int x
, int y
, HICON hicon
)
379 return DrawIconEx(hdc
,x
,y
,hicon
,0,0,0,NULL
, DI_NORMAL
) ;
385 //ifdef GetWindowProc
386 // #undef GetWindowProc
389 // #undef GetNextChild
392 // #endif // _WX_WINUNDEF_H_