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
271 inline HBITMAP
LoadBitmap(HINSTANCE hInstance
, LPCTSTR lpBitmapName
)
274 return LoadBitmapW(hInstance
, lpBitmapName
);
276 return LoadBitmapA(hInstance
, lpBitmapName
);
277 #endif // Unicode/ANSI
286 inline HINSTANCE
LoadLibrary(LPCWSTR lpLibFileName
)
288 return LoadLibraryW(lpLibFileName
);
291 inline HINSTANCE
LoadLibrary(LPCSTR lpLibFileName
)
293 return LoadLibraryA(lpLibFileName
);
302 inline HRSRC
FindResource(HMODULE hModule
, LPCWSTR lpName
, LPCWSTR lpType
)
304 return FindResourceW(hModule
, lpName
, lpType
);
307 inline HRSRC
FindResource(HMODULE hModule
, LPCSTR lpName
, LPCSTR lpType
)
309 return FindResourceA(hModule
, lpName
, lpType
);
318 inline BOOL
IsMaximized(HWND hwnd
)
320 return IsZoomed(hwnd
);
328 inline HWND
GetFirstChild(HWND hwnd
)
330 return GetTopWindow(hwnd
);
336 #ifdef GetPrevSibling
337 #undef GetPrevSibling
338 inline HWND
GetPrevSibling(HWND hwnd
)
340 return GetWindow(hwnd
,GW_HWNDPREV
);
346 #ifdef GetNextSibling
347 #undef GetNextSibling
348 inline HWND
GetNextSibling(HWND hwnd
)
350 return GetWindow(hwnd
,GW_HWNDNEXT
);
356 #if defined(GetWindowStyle)
357 #undef GetWindowStyle
360 // For ming and cygwin
365 inline HWND
GetFirstChild(HWND h
)
367 return GetTopWindow(h
);
373 #ifdef GetNextSibling
374 #undef GetNextSibling
375 inline HWND
GetNextSibling(HWND h
)
377 return GetWindow(h
, GW_HWNDNEXT
);
387 #if defined(__WXWINCE__) && defined(DrawIcon) //#ifdef DrawIcon
389 inline BOOL
DrawIcon(HDC hdc
, int x
, int y
, HICON hicon
)
391 return DrawIconEx(hdc
,x
,y
,hicon
,0,0,0,NULL
, DI_NORMAL
) ;
397 //ifdef GetWindowProc
398 // #undef GetWindowProc
401 // #undef GetNextChild
404 // #endif // _WX_WINUNDEF_H_