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