]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/winundef.h
Fixed bug #1022383: 'several ComboBoxes appear selected'
[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$
77ffb593 8// Copyright: (c) wxWidgets team
65571936 9// Licence: wxWindows licence
98216d40
VZ
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
7344726a
VZ
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
731db709
VZ
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
2b5f62a0
VZ
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
6bbd3344
BM
100// GetCharWidth
101
98216d40 102#ifdef GetCharWidth
379a3b04
BM
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 }
e90babdf 112#endif
6bbd3344
BM
113
114// FindWindow
115
98216d40 116#ifdef FindWindow
379a3b04
BM
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
e90babdf 129#endif
6bbd3344 130
13ff9344
JS
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
6bbd3344
BM
148// GetClassName
149
98216d40 150#ifdef GetClassName
379a3b04
BM
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
e90babdf 163#endif
6bbd3344
BM
164
165// GetClassInfo
166
98216d40 167#ifdef GetClassInfo
379a3b04
BM
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
e90babdf 180#endif
6bbd3344
BM
181
182// LoadAccelerators
183
98216d40 184#ifdef LoadAccelerators
379a3b04
BM
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
98216d40 197#endif
6bbd3344
BM
198
199// DrawText
200
98216d40 201#ifdef DrawText
379a3b04
BM
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
e90babdf 214#endif
6bbd3344 215
4ccf704a
VZ
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
6bbd3344
BM
229// StartDoc
230
98216d40 231#ifdef StartDoc
379a3b04 232 #undef StartDoc
d8c72298 233 #if defined( __GNUG__ ) && !wxCHECK_W32API_VERSION( 0, 5 )
0c589ad0
BM
234 #define DOCINFOW DOCINFO
235 #define DOCINFOA DOCINFO
236 #endif
379a3b04
BM
237 #ifdef _UNICODE
238 inline int StartDoc(HDC h, CONST DOCINFOW* info)
239 {
d8c72298 240 return StartDocW(h, (DOCINFOW*) info);
379a3b04
BM
241 }
242 #else
243 inline int StartDoc(HDC h, CONST DOCINFOA* info)
244 {
d8c72298 245 return StartDocA(h, (DOCINFOA*) info);
379a3b04
BM
246 }
247 #endif
98216d40
VZ
248#endif
249
379a3b04
BM
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);
6ec9d18f
RD
260 #endif
261 }
262#endif
263
7cc98b3e 264// GetMessage
6ec9d18f
RD
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
379a3b04 275 }
e90babdf 276#endif
98216d40 277
8b39c006
VZ
278// LoadIcon
279#ifdef LoadIcon
280 #undef LoadIcon
5e2411ab 281 inline HICON LoadIcon(HINSTANCE hInstance, LPCTSTR lpIconName)
8b39c006
VZ
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
381adb74
VZ
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
8b39c006 303
7cc98b3e
VZ
304// LoadLibrary
305
306#ifdef LoadLibrary
307 #undef LoadLibrary
7cc98b3e 308 #ifdef _UNICODE
f6bcfd97
BP
309 inline HINSTANCE LoadLibrary(LPCWSTR lpLibFileName)
310 {
7cc98b3e 311 return LoadLibraryW(lpLibFileName);
f6bcfd97 312 }
7cc98b3e 313 #else
f6bcfd97
BP
314 inline HINSTANCE LoadLibrary(LPCSTR lpLibFileName)
315 {
7cc98b3e 316 return LoadLibraryA(lpLibFileName);
7cc98b3e 317 }
f6bcfd97 318 #endif
7cc98b3e
VZ
319#endif
320
b568d04f
VZ
321// FindResource
322#ifdef FindResource
323 #undef FindResource
b568d04f 324 #ifdef _UNICODE
f6bcfd97
BP
325 inline HRSRC FindResource(HMODULE hModule, LPCWSTR lpName, LPCWSTR lpType)
326 {
b568d04f 327 return FindResourceW(hModule, lpName, lpType);
f6bcfd97 328 }
b568d04f 329 #else
f6bcfd97
BP
330 inline HRSRC FindResource(HMODULE hModule, LPCSTR lpName, LPCSTR lpType)
331 {
b568d04f 332 return FindResourceA(hModule, lpName, lpType);
b568d04f 333 }
f6bcfd97 334 #endif
b568d04f
VZ
335#endif
336
3372145d
PA
337// IsMaximized
338
339#ifdef IsMaximized
340 #undef IsMaximized
341 inline BOOL IsMaximized(HWND hwnd)
342 {
42d11c8e 343#ifdef __WXWINCE__
f428e6c5 344 wxUnusedVar(hwnd);
42d11c8e
JS
345 return FALSE;
346#else
3372145d 347 return IsZoomed(hwnd);
42d11c8e 348#endif
3372145d
PA
349 }
350#endif
351
2ba3d4f0
PA
352// GetFirstChild
353
354#ifdef GetFirstChild
355 #undef GetFirstChild
356 inline HWND GetFirstChild(HWND hwnd)
357 {
42d11c8e 358#ifdef __WXWINCE__
f428e6c5 359 wxUnusedVar(hwnd);
42d11c8e
JS
360 return 0;
361#else
2ba3d4f0 362 return GetTopWindow(hwnd);
42d11c8e 363#endif
2ba3d4f0
PA
364 }
365#endif
366
79bc2382
PA
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
c455ab93
RR
387// For WINE
388
b4da152e 389#if defined(GetWindowStyle)
c455ab93
RR
390 #undef GetWindowStyle
391#endif
98216d40 392
379a3b04 393// For ming and cygwin
6bbd3344 394
379a3b04
BM
395// GetFirstChild
396#ifdef GetFirstChild
397 #undef GetFirstChild
398 inline HWND GetFirstChild(HWND h)
399 {
400 return GetTopWindow(h);
401 }
402#endif
6bbd3344 403
98216d40 404
379a3b04
BM
405// GetNextSibling
406#ifdef GetNextSibling
0c589ad0
BM
407 #undef GetNextSibling
408 inline HWND GetNextSibling(HWND h)
409 {
410 return GetWindow(h, GW_HWNDNEXT);
411 }
98216d40
VZ
412#endif
413
73c13bb9
RD
414
415#ifdef Yield
416 #undef Yield
417#endif
418
368c9c6d
JS
419
420#if defined(__WXWINCE__) && defined(DrawIcon) //#ifdef DrawIcon
421 #undef DrawIcon
27d2dbbc 422 inline BOOL DrawIcon(HDC hdc, int x, int y, HICON hicon)
368c9c6d
JS
423 {
424 return DrawIconEx(hdc,x,y,hicon,0,0,0,NULL, DI_NORMAL) ;
425 }
426#endif
427
428
379a3b04
BM
429// GetWindowProc
430//ifdef GetWindowProc
431// #undef GetWindowProc
432//endif
433//ifdef GetNextChild
434// #undef GetNextChild
435//endif
6bbd3344 436
25889d3c
JS
437// #endif // _WX_WINUNDEF_H_
438