]>
Commit | Line | Data |
---|---|---|
98216d40 VZ |
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 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) wxWindows team | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
25889d3c JS |
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 | |
14 | * a 2nd time -- JACS | |
98216d40 VZ |
15 | #ifndef _WX_WINUNDEF_H_ |
16 | #define _WX_WINUNDEF_H_ | |
25889d3c | 17 | */ |
98216d40 | 18 | |
7cc98b3e VZ |
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. | |
23 | // | |
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 | // ---------------------------------------------------------------------------- | |
6bbd3344 | 27 | |
b225f659 VZ |
28 | // CreateDialog |
29 | ||
368c9c6d JS |
30 | //#ifdef(CreateDialog) |
31 | #if !defined(__WXWINCE__) && defined(CreateDialog) | |
b225f659 VZ |
32 | #undef CreateDialog |
33 | ||
34 | inline HWND CreateDialog(HINSTANCE hInstance, | |
35 | LPCTSTR pTemplate, | |
36 | HWND hwndParent, | |
37 | DLGPROC pDlgProc) | |
38 | { | |
39 | #ifdef _UNICODE | |
40 | return CreateDialogW(hInstance, pTemplate, hwndParent, pDlgProc); | |
41 | #else | |
42 | return CreateDialogA(hInstance, pTemplate, hwndParent, pDlgProc); | |
43 | #endif | |
44 | } | |
45 | #endif | |
46 | ||
731db709 VZ |
47 | // LoadMenu |
48 | ||
49 | #ifdef LoadMenu | |
50 | #undef LoadMenu | |
51 | ||
52 | inline HMENU LoadMenu(HINSTANCE instance, LPCTSTR name) | |
53 | { | |
54 | #ifdef _UNICODE | |
55 | return LoadMenuW(instance, name); | |
56 | #else | |
57 | return LoadMenuA(instance, name); | |
58 | #endif | |
59 | } | |
60 | #endif | |
61 | ||
2b5f62a0 VZ |
62 | // FindText |
63 | ||
64 | #ifdef FindText | |
65 | #undef FindText | |
66 | ||
67 | inline HWND APIENTRY FindText(LPFINDREPLACE lpfindreplace) | |
68 | { | |
69 | #ifdef UNICODE | |
70 | return FindTextW(lpfindreplace); | |
71 | #else | |
72 | return FindTextA(lpfindreplace); | |
73 | #endif // !UNICODE | |
74 | } | |
75 | #endif | |
76 | ||
6bbd3344 BM |
77 | // GetCharWidth |
78 | ||
98216d40 | 79 | #ifdef GetCharWidth |
379a3b04 BM |
80 | #undef GetCharWidth |
81 | inline BOOL GetCharWidth(HDC dc, UINT first, UINT last, LPINT buffer) | |
82 | { | |
83 | #ifdef _UNICODE | |
84 | return GetCharWidthW(dc, first, last, buffer); | |
85 | #else | |
86 | return GetCharWidthA(dc, first, last, buffer); | |
87 | #endif | |
88 | } | |
e90babdf | 89 | #endif |
6bbd3344 BM |
90 | |
91 | // FindWindow | |
92 | ||
98216d40 | 93 | #ifdef FindWindow |
379a3b04 BM |
94 | #undef FindWindow |
95 | #ifdef _UNICODE | |
96 | inline HWND FindWindow(LPCWSTR classname, LPCWSTR windowname) | |
97 | { | |
98 | return FindWindowW(classname, windowname); | |
99 | } | |
100 | #else | |
101 | inline HWND FindWindow(LPCSTR classname, LPCSTR windowname) | |
102 | { | |
103 | return FindWindowA(classname, windowname); | |
104 | } | |
105 | #endif | |
e90babdf | 106 | #endif |
6bbd3344 | 107 | |
13ff9344 JS |
108 | // PlaySound |
109 | ||
110 | #ifdef PlaySound | |
111 | #undef PlaySound | |
112 | #ifdef _UNICODE | |
113 | inline BOOL PlaySound(LPCWSTR pszSound, HMODULE hMod, DWORD fdwSound) | |
114 | { | |
115 | return PlaySoundW(pszSound, hMod, fdwSound); | |
116 | } | |
117 | #else | |
118 | inline BOOL PlaySound(LPCSTR pszSound, HMODULE hMod, DWORD fdwSound) | |
119 | { | |
120 | return PlaySoundA(pszSound, hMod, fdwSound); | |
121 | } | |
122 | #endif | |
123 | #endif | |
124 | ||
6bbd3344 BM |
125 | // GetClassName |
126 | ||
98216d40 | 127 | #ifdef GetClassName |
379a3b04 BM |
128 | #undef GetClassName |
129 | #ifdef _UNICODE | |
130 | inline int GetClassName(HWND h, LPWSTR classname, int maxcount) | |
131 | { | |
132 | return GetClassNameW(h, classname, maxcount); | |
133 | } | |
134 | #else | |
135 | inline int GetClassName(HWND h, LPSTR classname, int maxcount) | |
136 | { | |
137 | return GetClassNameA(h, classname, maxcount); | |
138 | } | |
139 | #endif | |
e90babdf | 140 | #endif |
6bbd3344 BM |
141 | |
142 | // GetClassInfo | |
143 | ||
98216d40 | 144 | #ifdef GetClassInfo |
379a3b04 BM |
145 | #undef GetClassInfo |
146 | #ifdef _UNICODE | |
147 | inline BOOL GetClassInfo(HINSTANCE h, LPCWSTR name, LPWNDCLASSW winclass) | |
148 | { | |
149 | return GetClassInfoW(h, name, winclass); | |
150 | } | |
151 | #else | |
152 | inline BOOL GetClassInfo(HINSTANCE h, LPCSTR name, LPWNDCLASSA winclass) | |
153 | { | |
154 | return GetClassInfoA(h, name, winclass); | |
155 | } | |
156 | #endif | |
e90babdf | 157 | #endif |
6bbd3344 BM |
158 | |
159 | // LoadAccelerators | |
160 | ||
98216d40 | 161 | #ifdef LoadAccelerators |
379a3b04 BM |
162 | #undef LoadAccelerators |
163 | #ifdef _UNICODE | |
164 | inline HACCEL LoadAccelerators(HINSTANCE h, LPCWSTR name) | |
165 | { | |
166 | return LoadAcceleratorsW(h, name); | |
167 | } | |
168 | #else | |
169 | inline HACCEL LoadAccelerators(HINSTANCE h, LPCSTR name) | |
170 | { | |
171 | return LoadAcceleratorsA(h, name); | |
172 | } | |
173 | #endif | |
98216d40 | 174 | #endif |
6bbd3344 BM |
175 | |
176 | // DrawText | |
177 | ||
98216d40 | 178 | #ifdef DrawText |
379a3b04 BM |
179 | #undef DrawText |
180 | #ifdef _UNICODE | |
181 | inline int DrawText(HDC h, LPCWSTR str, int count, LPRECT rect, UINT format) | |
182 | { | |
183 | return DrawTextW(h, str, count, rect, format); | |
184 | } | |
185 | #else | |
186 | inline int DrawText(HDC h, LPCSTR str, int count, LPRECT rect, UINT format) | |
187 | { | |
188 | return DrawTextA(h, str, count, rect, format); | |
189 | } | |
190 | #endif | |
e90babdf | 191 | #endif |
6bbd3344 | 192 | |
4ccf704a VZ |
193 | |
194 | /* | |
195 | When this file is included, sometimes the wxCHECK_W32API_VERSION macro | |
196 | is undefined. With for example CodeWarrior this gives problems with | |
197 | the following code: | |
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. | |
201 | */ | |
202 | #if !defined(__GNUG__) && !defined(wxCHECK_W32API_VERSION) | |
203 | #define wxCHECK_W32API_VERSION(maj, min) (0) | |
204 | #endif | |
205 | ||
6bbd3344 BM |
206 | // StartDoc |
207 | ||
98216d40 | 208 | #ifdef StartDoc |
379a3b04 | 209 | #undef StartDoc |
d8c72298 | 210 | #if defined( __GNUG__ ) && !wxCHECK_W32API_VERSION( 0, 5 ) |
0c589ad0 BM |
211 | #define DOCINFOW DOCINFO |
212 | #define DOCINFOA DOCINFO | |
213 | #endif | |
379a3b04 BM |
214 | #ifdef _UNICODE |
215 | inline int StartDoc(HDC h, CONST DOCINFOW* info) | |
216 | { | |
d8c72298 | 217 | return StartDocW(h, (DOCINFOW*) info); |
379a3b04 BM |
218 | } |
219 | #else | |
220 | inline int StartDoc(HDC h, CONST DOCINFOA* info) | |
221 | { | |
d8c72298 | 222 | return StartDocA(h, (DOCINFOA*) info); |
379a3b04 BM |
223 | } |
224 | #endif | |
98216d40 VZ |
225 | #endif |
226 | ||
379a3b04 BM |
227 | // GetObject |
228 | ||
229 | #ifdef GetObject | |
230 | #undef GetObject | |
231 | inline int GetObject(HGDIOBJ h, int i, LPVOID buffer) | |
232 | { | |
233 | #ifdef _UNICODE | |
234 | return GetObjectW(h, i, buffer); | |
235 | #else | |
236 | return GetObjectA(h, i, buffer); | |
6ec9d18f RD |
237 | #endif |
238 | } | |
239 | #endif | |
240 | ||
7cc98b3e | 241 | // GetMessage |
6ec9d18f RD |
242 | |
243 | #ifdef GetMessage | |
244 | #undef GetMessage | |
245 | inline int GetMessage(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax) | |
246 | { | |
247 | #ifdef _UNICODE | |
248 | return GetMessageW(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax); | |
249 | #else | |
250 | return GetMessageA(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax); | |
251 | #endif | |
379a3b04 | 252 | } |
e90babdf | 253 | #endif |
98216d40 | 254 | |
8b39c006 VZ |
255 | // LoadIcon |
256 | #ifdef LoadIcon | |
257 | #undef LoadIcon | |
5e2411ab | 258 | inline HICON LoadIcon(HINSTANCE hInstance, LPCTSTR lpIconName) |
8b39c006 VZ |
259 | { |
260 | #ifdef _UNICODE | |
261 | return LoadIconW(hInstance, lpIconName); | |
262 | #else // ANSI | |
263 | return LoadIconA(hInstance, lpIconName); | |
264 | #endif // Unicode/ANSI | |
265 | } | |
266 | #endif // LoadIcon | |
267 | ||
381adb74 VZ |
268 | // LoadBitmap |
269 | #ifdef LoadBitmap | |
270 | #undef LoadBitmap | |
271 | inline HBITMAP LoadBitmap(HINSTANCE hInstance, LPCTSTR lpBitmapName) | |
272 | { | |
273 | #ifdef _UNICODE | |
274 | return LoadBitmapW(hInstance, lpBitmapName); | |
275 | #else // ANSI | |
276 | return LoadBitmapA(hInstance, lpBitmapName); | |
277 | #endif // Unicode/ANSI | |
278 | } | |
279 | #endif // LoadBitmap | |
8b39c006 | 280 | |
7cc98b3e VZ |
281 | // LoadLibrary |
282 | ||
283 | #ifdef LoadLibrary | |
284 | #undef LoadLibrary | |
7cc98b3e | 285 | #ifdef _UNICODE |
f6bcfd97 BP |
286 | inline HINSTANCE LoadLibrary(LPCWSTR lpLibFileName) |
287 | { | |
7cc98b3e | 288 | return LoadLibraryW(lpLibFileName); |
f6bcfd97 | 289 | } |
7cc98b3e | 290 | #else |
f6bcfd97 BP |
291 | inline HINSTANCE LoadLibrary(LPCSTR lpLibFileName) |
292 | { | |
7cc98b3e | 293 | return LoadLibraryA(lpLibFileName); |
7cc98b3e | 294 | } |
f6bcfd97 | 295 | #endif |
7cc98b3e VZ |
296 | #endif |
297 | ||
b568d04f VZ |
298 | // FindResource |
299 | #ifdef FindResource | |
300 | #undef FindResource | |
b568d04f | 301 | #ifdef _UNICODE |
f6bcfd97 BP |
302 | inline HRSRC FindResource(HMODULE hModule, LPCWSTR lpName, LPCWSTR lpType) |
303 | { | |
b568d04f | 304 | return FindResourceW(hModule, lpName, lpType); |
f6bcfd97 | 305 | } |
b568d04f | 306 | #else |
f6bcfd97 BP |
307 | inline HRSRC FindResource(HMODULE hModule, LPCSTR lpName, LPCSTR lpType) |
308 | { | |
b568d04f | 309 | return FindResourceA(hModule, lpName, lpType); |
b568d04f | 310 | } |
f6bcfd97 | 311 | #endif |
b568d04f VZ |
312 | #endif |
313 | ||
3372145d PA |
314 | // IsMaximized |
315 | ||
316 | #ifdef IsMaximized | |
317 | #undef IsMaximized | |
318 | inline BOOL IsMaximized(HWND hwnd) | |
319 | { | |
320 | return IsZoomed(hwnd); | |
321 | } | |
322 | #endif | |
323 | ||
2ba3d4f0 PA |
324 | // GetFirstChild |
325 | ||
326 | #ifdef GetFirstChild | |
327 | #undef GetFirstChild | |
328 | inline HWND GetFirstChild(HWND hwnd) | |
329 | { | |
330 | return GetTopWindow(hwnd); | |
331 | } | |
332 | #endif | |
333 | ||
79bc2382 PA |
334 | // GetPrevSibling |
335 | ||
336 | #ifdef GetPrevSibling | |
337 | #undef GetPrevSibling | |
338 | inline HWND GetPrevSibling(HWND hwnd) | |
339 | { | |
340 | return GetWindow(hwnd,GW_HWNDPREV); | |
341 | } | |
342 | #endif | |
343 | ||
344 | // GetNextSibling | |
345 | ||
346 | #ifdef GetNextSibling | |
347 | #undef GetNextSibling | |
348 | inline HWND GetNextSibling(HWND hwnd) | |
349 | { | |
350 | return GetWindow(hwnd,GW_HWNDNEXT); | |
351 | } | |
352 | #endif | |
353 | ||
c455ab93 RR |
354 | // For WINE |
355 | ||
b4da152e | 356 | #if defined(GetWindowStyle) |
c455ab93 RR |
357 | #undef GetWindowStyle |
358 | #endif | |
98216d40 | 359 | |
379a3b04 | 360 | // For ming and cygwin |
6bbd3344 | 361 | |
379a3b04 BM |
362 | // GetFirstChild |
363 | #ifdef GetFirstChild | |
364 | #undef GetFirstChild | |
365 | inline HWND GetFirstChild(HWND h) | |
366 | { | |
367 | return GetTopWindow(h); | |
368 | } | |
369 | #endif | |
6bbd3344 | 370 | |
98216d40 | 371 | |
379a3b04 BM |
372 | // GetNextSibling |
373 | #ifdef GetNextSibling | |
0c589ad0 BM |
374 | #undef GetNextSibling |
375 | inline HWND GetNextSibling(HWND h) | |
376 | { | |
377 | return GetWindow(h, GW_HWNDNEXT); | |
378 | } | |
98216d40 VZ |
379 | #endif |
380 | ||
73c13bb9 RD |
381 | |
382 | #ifdef Yield | |
383 | #undef Yield | |
384 | #endif | |
385 | ||
368c9c6d JS |
386 | |
387 | #if defined(__WXWINCE__) && defined(DrawIcon) //#ifdef DrawIcon | |
388 | #undef DrawIcon | |
389 | inline BOOL DrawIcon(HDC hdc, int x, int y, HICON hicon) | |
390 | { | |
391 | return DrawIconEx(hdc,x,y,hicon,0,0,0,NULL, DI_NORMAL) ; | |
392 | } | |
393 | #endif | |
394 | ||
395 | ||
379a3b04 BM |
396 | // GetWindowProc |
397 | //ifdef GetWindowProc | |
398 | // #undef GetWindowProc | |
399 | //endif | |
400 | //ifdef GetNextChild | |
401 | // #undef GetNextChild | |
402 | //endif | |
6bbd3344 | 403 | |
25889d3c JS |
404 | // #endif // _WX_WINUNDEF_H_ |
405 |