]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/winundef.h
make it non mach-o carbon savvy
[wxWidgets.git] / include / wx / msw / winundef.h
CommitLineData
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
fb86251b 30#if defined(CreateDialog)
b225f659
VZ
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
731db709
VZ
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
2b5f62a0
VZ
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
6bbd3344
BM
76// GetCharWidth
77
98216d40 78#ifdef GetCharWidth
379a3b04
BM
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 }
e90babdf 88#endif
6bbd3344
BM
89
90// FindWindow
91
98216d40 92#ifdef FindWindow
379a3b04
BM
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
e90babdf 105#endif
6bbd3344 106
13ff9344
JS
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
6bbd3344
BM
124// GetClassName
125
98216d40 126#ifdef GetClassName
379a3b04
BM
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
e90babdf 139#endif
6bbd3344
BM
140
141// GetClassInfo
142
98216d40 143#ifdef GetClassInfo
379a3b04
BM
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
e90babdf 156#endif
6bbd3344
BM
157
158// LoadAccelerators
159
98216d40 160#ifdef LoadAccelerators
379a3b04
BM
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
98216d40 173#endif
6bbd3344
BM
174
175// DrawText
176
98216d40 177#ifdef DrawText
379a3b04
BM
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
e90babdf 190#endif
6bbd3344 191
4ccf704a
VZ
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
6bbd3344
BM
205// StartDoc
206
98216d40 207#ifdef StartDoc
379a3b04 208 #undef StartDoc
d8c72298 209 #if defined( __GNUG__ ) && !wxCHECK_W32API_VERSION( 0, 5 )
0c589ad0
BM
210 #define DOCINFOW DOCINFO
211 #define DOCINFOA DOCINFO
212 #endif
379a3b04
BM
213 #ifdef _UNICODE
214 inline int StartDoc(HDC h, CONST DOCINFOW* info)
215 {
d8c72298 216 return StartDocW(h, (DOCINFOW*) info);
379a3b04
BM
217 }
218 #else
219 inline int StartDoc(HDC h, CONST DOCINFOA* info)
220 {
d8c72298 221 return StartDocA(h, (DOCINFOA*) info);
379a3b04
BM
222 }
223 #endif
98216d40
VZ
224#endif
225
379a3b04
BM
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);
6ec9d18f
RD
236 #endif
237 }
238#endif
239
7cc98b3e 240// GetMessage
6ec9d18f
RD
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
379a3b04 251 }
e90babdf 252#endif
98216d40 253
8b39c006
VZ
254// LoadIcon
255#ifdef LoadIcon
256 #undef LoadIcon
5e2411ab 257 inline HICON LoadIcon(HINSTANCE hInstance, LPCTSTR lpIconName)
8b39c006
VZ
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
381adb74
VZ
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
8b39c006 279
7cc98b3e
VZ
280// LoadLibrary
281
282#ifdef LoadLibrary
283 #undef LoadLibrary
7cc98b3e 284 #ifdef _UNICODE
f6bcfd97
BP
285 inline HINSTANCE LoadLibrary(LPCWSTR lpLibFileName)
286 {
7cc98b3e 287 return LoadLibraryW(lpLibFileName);
f6bcfd97 288 }
7cc98b3e 289 #else
f6bcfd97
BP
290 inline HINSTANCE LoadLibrary(LPCSTR lpLibFileName)
291 {
7cc98b3e 292 return LoadLibraryA(lpLibFileName);
7cc98b3e 293 }
f6bcfd97 294 #endif
7cc98b3e
VZ
295#endif
296
b568d04f
VZ
297// FindResource
298#ifdef FindResource
299 #undef FindResource
b568d04f 300 #ifdef _UNICODE
f6bcfd97
BP
301 inline HRSRC FindResource(HMODULE hModule, LPCWSTR lpName, LPCWSTR lpType)
302 {
b568d04f 303 return FindResourceW(hModule, lpName, lpType);
f6bcfd97 304 }
b568d04f 305 #else
f6bcfd97
BP
306 inline HRSRC FindResource(HMODULE hModule, LPCSTR lpName, LPCSTR lpType)
307 {
b568d04f 308 return FindResourceA(hModule, lpName, lpType);
b568d04f 309 }
f6bcfd97 310 #endif
b568d04f
VZ
311#endif
312
3372145d
PA
313// IsMaximized
314
315#ifdef IsMaximized
316 #undef IsMaximized
317 inline BOOL IsMaximized(HWND hwnd)
318 {
42d11c8e
JS
319#ifdef __WXWINCE__
320 return FALSE;
321#else
3372145d 322 return IsZoomed(hwnd);
42d11c8e 323#endif
3372145d
PA
324 }
325#endif
326
2ba3d4f0
PA
327// GetFirstChild
328
329#ifdef GetFirstChild
330 #undef GetFirstChild
331 inline HWND GetFirstChild(HWND hwnd)
332 {
42d11c8e
JS
333#ifdef __WXWINCE__
334 return 0;
335#else
2ba3d4f0 336 return GetTopWindow(hwnd);
42d11c8e 337#endif
2ba3d4f0
PA
338 }
339#endif
340
79bc2382
PA
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
c455ab93
RR
361// For WINE
362
b4da152e 363#if defined(GetWindowStyle)
c455ab93
RR
364 #undef GetWindowStyle
365#endif
98216d40 366
379a3b04 367// For ming and cygwin
6bbd3344 368
379a3b04
BM
369// GetFirstChild
370#ifdef GetFirstChild
371 #undef GetFirstChild
372 inline HWND GetFirstChild(HWND h)
373 {
374 return GetTopWindow(h);
375 }
376#endif
6bbd3344 377
98216d40 378
379a3b04
BM
379// GetNextSibling
380#ifdef GetNextSibling
0c589ad0
BM
381 #undef GetNextSibling
382 inline HWND GetNextSibling(HWND h)
383 {
384 return GetWindow(h, GW_HWNDNEXT);
385 }
98216d40
VZ
386#endif
387
73c13bb9
RD
388
389#ifdef Yield
390 #undef Yield
391#endif
392
368c9c6d
JS
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
379a3b04
BM
403// GetWindowProc
404//ifdef GetWindowProc
405// #undef GetWindowProc
406//endif
407//ifdef GetNextChild
408// #undef GetNextChild
409//endif
6bbd3344 410
25889d3c
JS
411// #endif // _WX_WINUNDEF_H_
412