1 ///////////////////////////////////////////////////////////////////////////// 2 // Name: winundef.h 3 // Purpose: undefine the common symbols #define'd by <windows.h> 4 // Author: Vadim Zeitlin 5 // Modified by: 6 // Created: 16.05.99 7 // Copyright: (c) wxWidgets team 8 // Licence: wxWindows licence 9 ///////////////////////////////////////////////////////////////////////////// 10 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 13 * a 2nd time -- JACS 14 #ifndef _WX_WINUNDEF_H_ 15 #define _WX_WINUNDEF_H_ 16 */ 17 18 #ifndef wxUSE_UNICODE_WINDOWS_H 19 #ifdef _UNICODE 20 #define wxUSE_UNICODE_WINDOWS_H 1 21 #else 22 #define wxUSE_UNICODE_WINDOWS_H 0 23 #endif 24 #endif 25 26 // ---------------------------------------------------------------------------- 27 // windows.h #defines the following identifiers which are also used in wxWin so 28 // we replace these symbols with the corresponding inline functions and 29 // undefine the macro. 30 // 31 // This looks quite ugly here but allows us to write clear (and correct!) code 32 // elsewhere because the functions, unlike the macros, respect the scope. 33 // ---------------------------------------------------------------------------- 34 35 // CreateDialog 36 37 #if defined(CreateDialog) 38 #undef CreateDialog 39 CreateDialog(HINSTANCE hInstance,LPCTSTR pTemplate,HWND hwndParent,DLGPROC pDlgProc)40 inline HWND CreateDialog(HINSTANCE hInstance, 41 LPCTSTR pTemplate, 42 HWND hwndParent, 43 DLGPROC pDlgProc) 44 { 45 #if wxUSE_UNICODE_WINDOWS_H 46 return CreateDialogW(hInstance, pTemplate, hwndParent, pDlgProc); 47 #else 48 return CreateDialogA(hInstance, pTemplate, hwndParent, pDlgProc); 49 #endif 50 } 51 #endif 52 53 // CreateFont 54 55 #ifdef CreateFont 56 #undef CreateFont 57 CreateFont(int height,int width,int escapement,int orientation,int weight,DWORD italic,DWORD underline,DWORD strikeout,DWORD charset,DWORD outprecision,DWORD clipprecision,DWORD quality,DWORD family,LPCTSTR facename)58 inline HFONT CreateFont(int height, 59 int width, 60 int escapement, 61 int orientation, 62 int weight, 63 DWORD italic, 64 DWORD underline, 65 DWORD strikeout, 66 DWORD charset, 67 DWORD outprecision, 68 DWORD clipprecision, 69 DWORD quality, 70 DWORD family, 71 LPCTSTR facename) 72 { 73 #if wxUSE_UNICODE_WINDOWS_H 74 return CreateFontW(height, width, escapement, orientation, 75 weight, italic, underline, strikeout, charset, 76 outprecision, clipprecision, quality, 77 family, facename); 78 #else 79 return CreateFontA(height, width, escapement, orientation, 80 weight, italic, underline, strikeout, charset, 81 outprecision, clipprecision, quality, 82 family, facename); 83 #endif 84 } 85 #endif // CreateFont 86 87 // CreateWindow 88 89 #if defined(CreateWindow) 90 #undef CreateWindow 91 CreateWindow(LPCTSTR lpClassName,LPCTSTR lpWndClass,DWORD dwStyle,int x,int y,int w,int h,HWND hWndParent,HMENU hMenu,HINSTANCE hInstance,LPVOID lpParam)92 inline HWND CreateWindow(LPCTSTR lpClassName, 93 LPCTSTR lpWndClass, 94 DWORD dwStyle, 95 int x, int y, int w, int h, 96 HWND hWndParent, 97 HMENU hMenu, 98 HINSTANCE hInstance, 99 LPVOID lpParam) 100 { 101 #if wxUSE_UNICODE_WINDOWS_H 102 return CreateWindowW(lpClassName, lpWndClass, dwStyle, x, y, w, h, 103 hWndParent, hMenu, hInstance, lpParam); 104 #else 105 return CreateWindowA(lpClassName, lpWndClass, dwStyle, x, y, w, h, 106 hWndParent, hMenu, hInstance, lpParam); 107 #endif 108 } 109 #endif 110 111 // LoadMenu 112 113 #ifdef LoadMenu 114 #undef LoadMenu 115 LoadMenu(HINSTANCE instance,LPCTSTR name)116 inline HMENU LoadMenu(HINSTANCE instance, LPCTSTR name) 117 { 118 #if wxUSE_UNICODE_WINDOWS_H 119 return LoadMenuW(instance, name); 120 #else 121 return LoadMenuA(instance, name); 122 #endif 123 } 124 #endif 125 126 // FindText 127 128 #ifdef FindText 129 #undef FindText 130 FindText(LPFINDREPLACE lpfindreplace)131 inline HWND APIENTRY FindText(LPFINDREPLACE lpfindreplace) 132 { 133 #if wxUSE_UNICODE_WINDOWS_H 134 return FindTextW(lpfindreplace); 135 #else 136 return FindTextA(lpfindreplace); 137 #endif 138 } 139 #endif 140 141 // GetCharWidth 142 143 #ifdef GetCharWidth 144 #undef GetCharWidth GetCharWidth(HDC dc,UINT first,UINT last,LPINT buffer)145 inline BOOL GetCharWidth(HDC dc, UINT first, UINT last, LPINT buffer) 146 { 147 #if wxUSE_UNICODE_WINDOWS_H 148 return GetCharWidthW(dc, first, last, buffer); 149 #else 150 return GetCharWidthA(dc, first, last, buffer); 151 #endif 152 } 153 #endif 154 155 // FindWindow 156 157 #ifdef FindWindow 158 #undef FindWindow 159 #if wxUSE_UNICODE_WINDOWS_H FindWindow(LPCWSTR classname,LPCWSTR windowname)160 inline HWND FindWindow(LPCWSTR classname, LPCWSTR windowname) 161 { 162 return FindWindowW(classname, windowname); 163 } 164 #else FindWindow(LPCSTR classname,LPCSTR windowname)165 inline HWND FindWindow(LPCSTR classname, LPCSTR windowname) 166 { 167 return FindWindowA(classname, windowname); 168 } 169 #endif 170 #endif 171 172 // PlaySound 173 174 #ifdef PlaySound 175 #undef PlaySound 176 #if wxUSE_UNICODE_WINDOWS_H PlaySound(LPCWSTR pszSound,HMODULE hMod,DWORD fdwSound)177 inline BOOL PlaySound(LPCWSTR pszSound, HMODULE hMod, DWORD fdwSound) 178 { 179 return PlaySoundW(pszSound, hMod, fdwSound); 180 } 181 #else PlaySound(LPCSTR pszSound,HMODULE hMod,DWORD fdwSound)182 inline BOOL PlaySound(LPCSTR pszSound, HMODULE hMod, DWORD fdwSound) 183 { 184 return PlaySoundA(pszSound, hMod, fdwSound); 185 } 186 #endif 187 #endif 188 189 // GetClassName 190 191 #ifdef GetClassName 192 #undef GetClassName 193 #if wxUSE_UNICODE_WINDOWS_H GetClassName(HWND h,LPWSTR classname,int maxcount)194 inline int GetClassName(HWND h, LPWSTR classname, int maxcount) 195 { 196 return GetClassNameW(h, classname, maxcount); 197 } 198 #else GetClassName(HWND h,LPSTR classname,int maxcount)199 inline int GetClassName(HWND h, LPSTR classname, int maxcount) 200 { 201 return GetClassNameA(h, classname, maxcount); 202 } 203 #endif 204 #endif 205 206 // GetClassInfo 207 208 #ifdef GetClassInfo 209 #undef GetClassInfo 210 #if wxUSE_UNICODE_WINDOWS_H GetClassInfo(HINSTANCE h,LPCWSTR name,LPWNDCLASSW winclass)211 inline BOOL GetClassInfo(HINSTANCE h, LPCWSTR name, LPWNDCLASSW winclass) 212 { 213 return GetClassInfoW(h, name, winclass); 214 } 215 #else GetClassInfo(HINSTANCE h,LPCSTR name,LPWNDCLASSA winclass)216 inline BOOL GetClassInfo(HINSTANCE h, LPCSTR name, LPWNDCLASSA winclass) 217 { 218 return GetClassInfoA(h, name, winclass); 219 } 220 #endif 221 #endif 222 223 // LoadAccelerators 224 225 #ifdef LoadAccelerators 226 #undef LoadAccelerators 227 #if wxUSE_UNICODE_WINDOWS_H LoadAccelerators(HINSTANCE h,LPCWSTR name)228 inline HACCEL LoadAccelerators(HINSTANCE h, LPCWSTR name) 229 { 230 return LoadAcceleratorsW(h, name); 231 } 232 #else LoadAccelerators(HINSTANCE h,LPCSTR name)233 inline HACCEL LoadAccelerators(HINSTANCE h, LPCSTR name) 234 { 235 return LoadAcceleratorsA(h, name); 236 } 237 #endif 238 #endif 239 240 // DrawText 241 242 #ifdef DrawText 243 #undef DrawText 244 #if wxUSE_UNICODE_WINDOWS_H DrawText(HDC h,LPCWSTR str,int count,LPRECT rect,UINT format)245 inline int DrawText(HDC h, LPCWSTR str, int count, LPRECT rect, UINT format) 246 { 247 return DrawTextW(h, str, count, rect, format); 248 } 249 #else DrawText(HDC h,LPCSTR str,int count,LPRECT rect,UINT format)250 inline int DrawText(HDC h, LPCSTR str, int count, LPRECT rect, UINT format) 251 { 252 return DrawTextA(h, str, count, rect, format); 253 } 254 #endif 255 #endif 256 257 258 // StartDoc 259 260 #ifdef StartDoc 261 #undef StartDoc 262 263 #if wxUSE_UNICODE_WINDOWS_H StartDoc(HDC h,CONST DOCINFOW * info)264 inline int StartDoc(HDC h, CONST DOCINFOW* info) 265 { 266 return StartDocW(h, const_cast<DOCINFOW*>(info)); 267 } 268 #else StartDoc(HDC h,CONST DOCINFOA * info)269 inline int StartDoc(HDC h, CONST DOCINFOA* info) 270 { 271 return StartDocA(h, const_cast<DOCINFOA*>(info)); 272 } 273 #endif 274 #endif 275 276 // GetObject 277 278 #ifdef GetObject 279 #undef GetObject GetObject(HGDIOBJ h,int i,LPVOID buffer)280 inline int GetObject(HGDIOBJ h, int i, LPVOID buffer) 281 { 282 #if wxUSE_UNICODE_WINDOWS_H 283 return GetObjectW(h, i, buffer); 284 #else 285 return GetObjectA(h, i, buffer); 286 #endif 287 } 288 #endif 289 290 // GetMessage 291 292 #ifdef GetMessage 293 #undef GetMessage GetMessage(LPMSG lpMsg,HWND hWnd,UINT wMsgFilterMin,UINT wMsgFilterMax)294 inline int GetMessage(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax) 295 { 296 #if wxUSE_UNICODE_WINDOWS_H 297 return GetMessageW(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax); 298 #else 299 return GetMessageA(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax); 300 #endif 301 } 302 #endif 303 304 // LoadIcon 305 #ifdef LoadIcon 306 #undef LoadIcon LoadIcon(HINSTANCE hInstance,LPCTSTR lpIconName)307 inline HICON LoadIcon(HINSTANCE hInstance, LPCTSTR lpIconName) 308 { 309 #if wxUSE_UNICODE_WINDOWS_H 310 return LoadIconW(hInstance, lpIconName); 311 #else // ANSI 312 return LoadIconA(hInstance, lpIconName); 313 #endif // Unicode/ANSI 314 } 315 #endif // LoadIcon 316 317 // LoadBitmap 318 #ifdef LoadBitmap 319 #undef LoadBitmap LoadBitmap(HINSTANCE hInstance,LPCTSTR lpBitmapName)320 inline HBITMAP LoadBitmap(HINSTANCE hInstance, LPCTSTR lpBitmapName) 321 { 322 #if wxUSE_UNICODE_WINDOWS_H 323 return LoadBitmapW(hInstance, lpBitmapName); 324 #else // ANSI 325 return LoadBitmapA(hInstance, lpBitmapName); 326 #endif // Unicode/ANSI 327 } 328 #endif // LoadBitmap 329 330 // LoadLibrary 331 332 #ifdef LoadLibrary 333 #undef LoadLibrary 334 #if wxUSE_UNICODE_WINDOWS_H LoadLibrary(LPCWSTR lpLibFileName)335 inline HINSTANCE LoadLibrary(LPCWSTR lpLibFileName) 336 { 337 return LoadLibraryW(lpLibFileName); 338 } 339 #else LoadLibrary(LPCSTR lpLibFileName)340 inline HINSTANCE LoadLibrary(LPCSTR lpLibFileName) 341 { 342 return LoadLibraryA(lpLibFileName); 343 } 344 #endif 345 #endif 346 347 // FindResource 348 #ifdef FindResource 349 #undef FindResource 350 #if wxUSE_UNICODE_WINDOWS_H FindResource(HMODULE hModule,LPCWSTR lpName,LPCWSTR lpType)351 inline HRSRC FindResource(HMODULE hModule, LPCWSTR lpName, LPCWSTR lpType) 352 { 353 return FindResourceW(hModule, lpName, lpType); 354 } 355 #else FindResource(HMODULE hModule,LPCSTR lpName,LPCSTR lpType)356 inline HRSRC FindResource(HMODULE hModule, LPCSTR lpName, LPCSTR lpType) 357 { 358 return FindResourceA(hModule, lpName, lpType); 359 } 360 #endif 361 #endif 362 363 // IsMaximized 364 365 #ifdef IsMaximized 366 #undef IsMaximized IsMaximized(HWND hwnd)367 inline BOOL IsMaximized(HWND hwnd) 368 { 369 return IsZoomed(hwnd); 370 } 371 #endif 372 373 // GetFirstChild 374 375 #ifdef GetFirstChild 376 #undef GetFirstChild GetFirstChild(HWND hwnd)377 inline HWND GetFirstChild(HWND hwnd) 378 { 379 return GetTopWindow(hwnd); 380 } 381 #endif 382 383 // GetFirstSibling 384 385 #ifdef GetFirstSibling 386 #undef GetFirstSibling GetFirstSibling(HWND hwnd)387 inline HWND GetFirstSibling(HWND hwnd) 388 { 389 return GetWindow(hwnd,GW_HWNDFIRST); 390 } 391 #endif 392 393 // GetLastSibling 394 395 #ifdef GetLastSibling 396 #undef GetLastSibling GetLastSibling(HWND hwnd)397 inline HWND GetLastSibling(HWND hwnd) 398 { 399 return GetWindow(hwnd,GW_HWNDLAST); 400 } 401 #endif 402 403 // GetPrevSibling 404 405 #ifdef GetPrevSibling 406 #undef GetPrevSibling GetPrevSibling(HWND hwnd)407 inline HWND GetPrevSibling(HWND hwnd) 408 { 409 return GetWindow(hwnd,GW_HWNDPREV); 410 } 411 #endif 412 413 // GetNextSibling 414 415 #ifdef GetNextSibling 416 #undef GetNextSibling GetNextSibling(HWND hwnd)417 inline HWND GetNextSibling(HWND hwnd) 418 { 419 return GetWindow(hwnd,GW_HWNDNEXT); 420 } 421 #endif 422 423 // For WINE 424 425 #if defined(GetWindowStyle) 426 #undef GetWindowStyle 427 #endif 428 429 // For ming and cygwin 430 431 #ifdef Yield 432 #undef Yield 433 #endif 434 435 436 // GetWindowProc 437 //ifdef GetWindowProc 438 // #undef GetWindowProc 439 //endif 440 //ifdef GetNextChild 441 // #undef GetNextChild 442 //endif 443 444 // #endif // _WX_WINUNDEF_H_ 445 446