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