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
);
51 inline HFONT
CreateFont(int height
,
67 return CreateFontW(height
, width
, escapement
, orientation
,
68 weight
, italic
, underline
, strikeout
, charset
,
69 outprecision
, clipprecision
, quality
,
72 return CreateFontA(height
, width
, escapement
, orientation
,
73 weight
, italic
, underline
, strikeout
, charset
,
74 outprecision
, clipprecision
, quality
,
82 #if defined(CreateWindow)
85 inline HWND
CreateWindow(LPCTSTR lpClassName
,
88 int x
, int y
, int w
, int h
,
95 return CreateWindowW(lpClassName
, lpWndClass
, dwStyle
, x
, y
, w
, h
,
96 hWndParent
, hMenu
, hInstance
, lpParam
);
98 return CreateWindowA(lpClassName
, lpWndClass
, dwStyle
, x
, y
, w
, h
,
99 hWndParent
, hMenu
, hInstance
, lpParam
);
109 inline HMENU
LoadMenu(HINSTANCE instance
, LPCTSTR name
)
112 return LoadMenuW(instance
, name
);
114 return LoadMenuA(instance
, name
);
124 inline HWND APIENTRY
FindText(LPFINDREPLACE lpfindreplace
)
127 return FindTextW(lpfindreplace
);
129 return FindTextA(lpfindreplace
);
138 inline BOOL
GetCharWidth(HDC dc
, UINT first
, UINT last
, LPINT buffer
)
141 return GetCharWidthW(dc
, first
, last
, buffer
);
143 return GetCharWidthA(dc
, first
, last
, buffer
);
153 inline HWND
FindWindow(LPCWSTR classname
, LPCWSTR windowname
)
155 return FindWindowW(classname
, windowname
);
158 inline HWND
FindWindow(LPCSTR classname
, LPCSTR windowname
)
160 return FindWindowA(classname
, windowname
);
170 inline BOOL
PlaySound(LPCWSTR pszSound
, HMODULE hMod
, DWORD fdwSound
)
172 return PlaySoundW(pszSound
, hMod
, fdwSound
);
175 inline BOOL
PlaySound(LPCSTR pszSound
, HMODULE hMod
, DWORD fdwSound
)
177 return PlaySoundA(pszSound
, hMod
, fdwSound
);
187 inline int GetClassName(HWND h
, LPWSTR classname
, int maxcount
)
189 return GetClassNameW(h
, classname
, maxcount
);
192 inline int GetClassName(HWND h
, LPSTR classname
, int maxcount
)
194 return GetClassNameA(h
, classname
, maxcount
);
204 inline BOOL
GetClassInfo(HINSTANCE h
, LPCWSTR name
, LPWNDCLASSW winclass
)
206 return GetClassInfoW(h
, name
, winclass
);
209 inline BOOL
GetClassInfo(HINSTANCE h
, LPCSTR name
, LPWNDCLASSA winclass
)
211 return GetClassInfoA(h
, name
, winclass
);
218 #ifdef LoadAccelerators
219 #undef LoadAccelerators
221 inline HACCEL
LoadAccelerators(HINSTANCE h
, LPCWSTR name
)
223 return LoadAcceleratorsW(h
, name
);
226 inline HACCEL
LoadAccelerators(HINSTANCE h
, LPCSTR name
)
228 return LoadAcceleratorsA(h
, name
);
238 inline int DrawText(HDC h
, LPCWSTR str
, int count
, LPRECT rect
, UINT format
)
240 return DrawTextW(h
, str
, count
, rect
, format
);
243 inline int DrawText(HDC h
, LPCSTR str
, int count
, LPRECT rect
, UINT format
)
245 return DrawTextA(h
, str
, count
, rect
, format
);
252 When this file is included, sometimes the wxCHECK_W32API_VERSION macro
253 is undefined. With for example CodeWarrior this gives problems with
255 #if 0 && wxCHECK_W32API_VERSION( 0, 5 )
256 Because CodeWarrior does macro expansion before test evaluation.
257 We define wxCHECK_W32API_VERSION here if it's undefined.
259 #if !defined(__GNUG__) && !defined(wxCHECK_W32API_VERSION)
260 #define wxCHECK_W32API_VERSION(maj, min) (0)
267 #if defined( __GNUG__ ) && !wxCHECK_W32API_VERSION( 0, 5 )
268 #define DOCINFOW DOCINFO
269 #define DOCINFOA DOCINFO
272 inline int StartDoc(HDC h
, CONST DOCINFOW
* info
)
274 return StartDocW(h
, (DOCINFOW
*) info
);
277 inline int StartDoc(HDC h
, CONST DOCINFOA
* info
)
279 return StartDocA(h
, (DOCINFOA
*) info
);
288 inline int GetObject(HGDIOBJ h
, int i
, LPVOID buffer
)
291 return GetObjectW(h
, i
, buffer
);
293 return GetObjectA(h
, i
, buffer
);
302 inline int GetMessage(LPMSG lpMsg
, HWND hWnd
, UINT wMsgFilterMin
, UINT wMsgFilterMax
)
305 return GetMessageW(lpMsg
, hWnd
, wMsgFilterMin
, wMsgFilterMax
);
307 return GetMessageA(lpMsg
, hWnd
, wMsgFilterMin
, wMsgFilterMax
);
315 inline HICON
LoadIcon(HINSTANCE hInstance
, LPCTSTR lpIconName
)
318 return LoadIconW(hInstance
, lpIconName
);
320 return LoadIconA(hInstance
, lpIconName
);
321 #endif // Unicode/ANSI
328 inline HBITMAP
LoadBitmap(HINSTANCE hInstance
, LPCTSTR lpBitmapName
)
331 return LoadBitmapW(hInstance
, lpBitmapName
);
333 return LoadBitmapA(hInstance
, lpBitmapName
);
334 #endif // Unicode/ANSI
343 inline HINSTANCE
LoadLibrary(LPCWSTR lpLibFileName
)
345 return LoadLibraryW(lpLibFileName
);
348 inline HINSTANCE
LoadLibrary(LPCSTR lpLibFileName
)
350 return LoadLibraryA(lpLibFileName
);
359 inline HRSRC
FindResource(HMODULE hModule
, LPCWSTR lpName
, LPCWSTR lpType
)
361 return FindResourceW(hModule
, lpName
, lpType
);
364 inline HRSRC
FindResource(HMODULE hModule
, LPCSTR lpName
, LPCSTR lpType
)
366 return FindResourceA(hModule
, lpName
, lpType
);
375 inline BOOL
IsMaximized(HWND
WXUNUSED_IN_WINCE(hwnd
))
380 return IsZoomed(hwnd
);
389 inline HWND
GetFirstChild(HWND
WXUNUSED_IN_WINCE(hwnd
))
394 return GetTopWindow(hwnd
);
401 #ifdef GetFirstSibling
402 #undef GetFirstSibling
403 inline HWND
GetFirstSibling(HWND hwnd
)
405 return GetWindow(hwnd
,GW_HWNDFIRST
);
411 #ifdef GetLastSibling
412 #undef GetLastSibling
413 inline HWND
GetLastSibling(HWND hwnd
)
415 return GetWindow(hwnd
,GW_HWNDLAST
);
421 #ifdef GetPrevSibling
422 #undef GetPrevSibling
423 inline HWND
GetPrevSibling(HWND hwnd
)
425 return GetWindow(hwnd
,GW_HWNDPREV
);
431 #ifdef GetNextSibling
432 #undef GetNextSibling
433 inline HWND
GetNextSibling(HWND hwnd
)
435 return GetWindow(hwnd
,GW_HWNDNEXT
);
441 #if defined(GetWindowStyle)
442 #undef GetWindowStyle
445 // For ming and cygwin
450 inline HWND
GetFirstChild(HWND h
)
452 return GetTopWindow(h
);
458 #ifdef GetNextSibling
459 #undef GetNextSibling
460 inline HWND
GetNextSibling(HWND h
)
462 return GetWindow(h
, GW_HWNDNEXT
);
472 #if defined(__WXWINCE__) && defined(DrawIcon) //#ifdef DrawIcon
474 inline BOOL
DrawIcon(HDC hdc
, int x
, int y
, HICON hicon
)
476 return DrawIconEx(hdc
,x
,y
,hicon
,0,0,0,NULL
, DI_NORMAL
) ;
482 //ifdef GetWindowProc
483 // #undef GetWindowProc
486 // #undef GetNextChild
489 // #endif // _WX_WINUNDEF_H_