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 #if !defined(__WXWINCE__) && defined(CreateDialog)
31 // #if 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
)
323 return IsZoomed(hwnd
);
332 inline HWND
GetFirstChild(HWND hwnd
)
337 return GetTopWindow(hwnd
);
344 #ifdef GetPrevSibling
345 #undef GetPrevSibling
346 inline HWND
GetPrevSibling(HWND hwnd
)
348 return GetWindow(hwnd
,GW_HWNDPREV
);
354 #ifdef GetNextSibling
355 #undef GetNextSibling
356 inline HWND
GetNextSibling(HWND hwnd
)
358 return GetWindow(hwnd
,GW_HWNDNEXT
);
364 #if defined(GetWindowStyle)
365 #undef GetWindowStyle
368 // For ming and cygwin
373 inline HWND
GetFirstChild(HWND h
)
375 return GetTopWindow(h
);
381 #ifdef GetNextSibling
382 #undef GetNextSibling
383 inline HWND
GetNextSibling(HWND h
)
385 return GetWindow(h
, GW_HWNDNEXT
);
395 #if defined(__WXWINCE__) && defined(DrawIcon) //#ifdef DrawIcon
397 inline BOOL
DrawIcon(HDC hdc
, int x
, int y
, HICON hicon
)
399 return DrawIconEx(hdc
,x
,y
,hicon
,0,0,0,NULL
, DI_NORMAL
) ;
405 //ifdef GetWindowProc
406 // #undef GetWindowProc
409 // #undef GetNextChild
412 // #endif // _WX_WINUNDEF_H_