1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: undefine the common symbols #define'd by <windows.h>
4 // Author: Vadim Zeitlin
7 // Copyright: (c) wxWidgets team
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 /* THIS SHOULD NOT BE USED since you might include it once e.g. in window.h,
12 * then again _AFTER_ you've included windows.h, in which case it won't work
14 #ifndef _WX_WINUNDEF_H_
15 #define _WX_WINUNDEF_H_
18 // ----------------------------------------------------------------------------
19 // windows.h #defines the following identifiers which are also used in wxWin so
20 // we replace these symbols with the corresponding inline functions and
21 // undefine the macro.
23 // This looks quite ugly here but allows us to write clear (and correct!) code
24 // elsewhere because the functions, unlike the macros, respect the scope.
25 // ----------------------------------------------------------------------------
29 #if defined(CreateDialog)
32 inline HWND
CreateDialog(HINSTANCE hInstance
,
38 return CreateDialogW(hInstance
, pTemplate
, hwndParent
, pDlgProc
);
40 return CreateDialogA(hInstance
, pTemplate
, hwndParent
, pDlgProc
);
50 inline HFONT
CreateFont(int height
,
66 return CreateFontW(height
, width
, escapement
, orientation
,
67 weight
, italic
, underline
, strikeout
, charset
,
68 outprecision
, clipprecision
, quality
,
71 return CreateFontA(height
, width
, escapement
, orientation
,
72 weight
, italic
, underline
, strikeout
, charset
,
73 outprecision
, clipprecision
, quality
,
81 #if defined(CreateWindow)
84 inline HWND
CreateWindow(LPCTSTR lpClassName
,
87 int x
, int y
, int w
, int h
,
94 return CreateWindowW(lpClassName
, lpWndClass
, dwStyle
, x
, y
, w
, h
,
95 hWndParent
, hMenu
, hInstance
, lpParam
);
97 return CreateWindowA(lpClassName
, lpWndClass
, dwStyle
, x
, y
, w
, h
,
98 hWndParent
, hMenu
, hInstance
, lpParam
);
108 inline HMENU
LoadMenu(HINSTANCE instance
, LPCTSTR name
)
111 return LoadMenuW(instance
, name
);
113 return LoadMenuA(instance
, name
);
123 inline HWND APIENTRY
FindText(LPFINDREPLACE lpfindreplace
)
126 return FindTextW(lpfindreplace
);
128 return FindTextA(lpfindreplace
);
137 inline BOOL
GetCharWidth(HDC dc
, UINT first
, UINT last
, LPINT buffer
)
140 return GetCharWidthW(dc
, first
, last
, buffer
);
142 return GetCharWidthA(dc
, first
, last
, buffer
);
152 inline HWND
FindWindow(LPCWSTR classname
, LPCWSTR windowname
)
154 return FindWindowW(classname
, windowname
);
157 inline HWND
FindWindow(LPCSTR classname
, LPCSTR windowname
)
159 return FindWindowA(classname
, windowname
);
169 inline BOOL
PlaySound(LPCWSTR pszSound
, HMODULE hMod
, DWORD fdwSound
)
171 return PlaySoundW(pszSound
, hMod
, fdwSound
);
174 inline BOOL
PlaySound(LPCSTR pszSound
, HMODULE hMod
, DWORD fdwSound
)
176 return PlaySoundA(pszSound
, hMod
, fdwSound
);
186 inline int GetClassName(HWND h
, LPWSTR classname
, int maxcount
)
188 return GetClassNameW(h
, classname
, maxcount
);
191 inline int GetClassName(HWND h
, LPSTR classname
, int maxcount
)
193 return GetClassNameA(h
, classname
, maxcount
);
203 inline BOOL
GetClassInfo(HINSTANCE h
, LPCWSTR name
, LPWNDCLASSW winclass
)
205 return GetClassInfoW(h
, name
, winclass
);
208 inline BOOL
GetClassInfo(HINSTANCE h
, LPCSTR name
, LPWNDCLASSA winclass
)
210 return GetClassInfoA(h
, name
, winclass
);
217 #ifdef LoadAccelerators
218 #undef LoadAccelerators
220 inline HACCEL
LoadAccelerators(HINSTANCE h
, LPCWSTR name
)
222 return LoadAcceleratorsW(h
, name
);
225 inline HACCEL
LoadAccelerators(HINSTANCE h
, LPCSTR name
)
227 return LoadAcceleratorsA(h
, name
);
237 inline int DrawText(HDC h
, LPCWSTR str
, int count
, LPRECT rect
, UINT format
)
239 return DrawTextW(h
, str
, count
, rect
, format
);
242 inline int DrawText(HDC h
, LPCSTR str
, int count
, LPRECT rect
, UINT format
)
244 return DrawTextA(h
, str
, count
, rect
, format
);
255 // Work around a bug in very old MinGW headers that didn't define DOCINFOW
256 // and DOCINFOA but only DOCINFO in both ANSI and Unicode.
257 #if defined( __GNUG__ )
258 #if !wxCHECK_W32API_VERSION( 0, 5 )
259 #define DOCINFOW DOCINFO
260 #define DOCINFOA DOCINFO
265 inline int StartDoc(HDC h
, CONST DOCINFOW
* info
)
267 return StartDocW(h
, (DOCINFOW
*) info
);
270 inline int StartDoc(HDC h
, CONST DOCINFOA
* info
)
272 return StartDocA(h
, (DOCINFOA
*) info
);
281 inline int GetObject(HGDIOBJ h
, int i
, LPVOID buffer
)
284 return GetObjectW(h
, i
, buffer
);
286 return GetObjectA(h
, i
, buffer
);
295 inline int GetMessage(LPMSG lpMsg
, HWND hWnd
, UINT wMsgFilterMin
, UINT wMsgFilterMax
)
298 return GetMessageW(lpMsg
, hWnd
, wMsgFilterMin
, wMsgFilterMax
);
300 return GetMessageA(lpMsg
, hWnd
, wMsgFilterMin
, wMsgFilterMax
);
308 inline HICON
LoadIcon(HINSTANCE hInstance
, LPCTSTR lpIconName
)
311 return LoadIconW(hInstance
, lpIconName
);
313 return LoadIconA(hInstance
, lpIconName
);
314 #endif // Unicode/ANSI
321 inline HBITMAP
LoadBitmap(HINSTANCE hInstance
, LPCTSTR lpBitmapName
)
324 return LoadBitmapW(hInstance
, lpBitmapName
);
326 return LoadBitmapA(hInstance
, lpBitmapName
);
327 #endif // Unicode/ANSI
336 inline HINSTANCE
LoadLibrary(LPCWSTR lpLibFileName
)
338 return LoadLibraryW(lpLibFileName
);
341 inline HINSTANCE
LoadLibrary(LPCSTR lpLibFileName
)
343 return LoadLibraryA(lpLibFileName
);
352 inline HRSRC
FindResource(HMODULE hModule
, LPCWSTR lpName
, LPCWSTR lpType
)
354 return FindResourceW(hModule
, lpName
, lpType
);
357 inline HRSRC
FindResource(HMODULE hModule
, LPCSTR lpName
, LPCSTR lpType
)
359 return FindResourceA(hModule
, lpName
, lpType
);
368 inline BOOL
IsMaximized(HWND
WXUNUSED_IN_WINCE(hwnd
))
373 return IsZoomed(hwnd
);
382 inline HWND
GetFirstChild(HWND
WXUNUSED_IN_WINCE(hwnd
))
387 return GetTopWindow(hwnd
);
394 #ifdef GetFirstSibling
395 #undef GetFirstSibling
396 inline HWND
GetFirstSibling(HWND hwnd
)
398 return GetWindow(hwnd
,GW_HWNDFIRST
);
404 #ifdef GetLastSibling
405 #undef GetLastSibling
406 inline HWND
GetLastSibling(HWND hwnd
)
408 return GetWindow(hwnd
,GW_HWNDLAST
);
414 #ifdef GetPrevSibling
415 #undef GetPrevSibling
416 inline HWND
GetPrevSibling(HWND hwnd
)
418 return GetWindow(hwnd
,GW_HWNDPREV
);
424 #ifdef GetNextSibling
425 #undef GetNextSibling
426 inline HWND
GetNextSibling(HWND hwnd
)
428 return GetWindow(hwnd
,GW_HWNDNEXT
);
434 #if defined(GetWindowStyle)
435 #undef GetWindowStyle
438 // For ming and cygwin
443 inline HWND
GetFirstChild(HWND h
)
445 return GetTopWindow(h
);
451 #ifdef GetNextSibling
452 #undef GetNextSibling
453 inline HWND
GetNextSibling(HWND h
)
455 return GetWindow(h
, GW_HWNDNEXT
);
465 #if defined(__WXWINCE__) && defined(DrawIcon) //#ifdef DrawIcon
467 inline BOOL
DrawIcon(HDC hdc
, int x
, int y
, HICON hicon
)
469 return DrawIconEx(hdc
,x
,y
,hicon
,0,0,0,NULL
, DI_NORMAL
) ;
475 //ifdef GetWindowProc
476 // #undef GetWindowProc
479 // #undef GetNextChild
482 // #endif // _WX_WINUNDEF_H_