]>
Commit | Line | Data |
---|---|---|
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 | #ifdef 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 | // GetCharWidth | |
62 | ||
63 | #ifdef GetCharWidth | |
64 | #undef GetCharWidth | |
65 | inline BOOL GetCharWidth(HDC dc, UINT first, UINT last, LPINT buffer) | |
66 | { | |
67 | #ifdef _UNICODE | |
68 | return GetCharWidthW(dc, first, last, buffer); | |
69 | #else | |
70 | return GetCharWidthA(dc, first, last, buffer); | |
71 | #endif | |
72 | } | |
73 | #endif | |
74 | ||
75 | // FindWindow | |
76 | ||
77 | #ifdef FindWindow | |
78 | #undef FindWindow | |
79 | #ifdef _UNICODE | |
80 | inline HWND FindWindow(LPCWSTR classname, LPCWSTR windowname) | |
81 | { | |
82 | return FindWindowW(classname, windowname); | |
83 | } | |
84 | #else | |
85 | inline HWND FindWindow(LPCSTR classname, LPCSTR windowname) | |
86 | { | |
87 | return FindWindowA(classname, windowname); | |
88 | } | |
89 | #endif | |
90 | #endif | |
91 | ||
92 | // PlaySound | |
93 | ||
94 | #ifdef PlaySound | |
95 | #undef PlaySound | |
96 | #ifdef _UNICODE | |
97 | inline BOOL PlaySound(LPCWSTR pszSound, HMODULE hMod, DWORD fdwSound) | |
98 | { | |
99 | return PlaySoundW(pszSound, hMod, fdwSound); | |
100 | } | |
101 | #else | |
102 | inline BOOL PlaySound(LPCSTR pszSound, HMODULE hMod, DWORD fdwSound) | |
103 | { | |
104 | return PlaySoundA(pszSound, hMod, fdwSound); | |
105 | } | |
106 | #endif | |
107 | #endif | |
108 | ||
109 | // GetClassName | |
110 | ||
111 | #ifdef GetClassName | |
112 | #undef GetClassName | |
113 | #ifdef _UNICODE | |
114 | inline int GetClassName(HWND h, LPWSTR classname, int maxcount) | |
115 | { | |
116 | return GetClassNameW(h, classname, maxcount); | |
117 | } | |
118 | #else | |
119 | inline int GetClassName(HWND h, LPSTR classname, int maxcount) | |
120 | { | |
121 | return GetClassNameA(h, classname, maxcount); | |
122 | } | |
123 | #endif | |
124 | #endif | |
125 | ||
126 | // GetClassInfo | |
127 | ||
128 | #ifdef GetClassInfo | |
129 | #undef GetClassInfo | |
130 | #ifdef _UNICODE | |
131 | inline BOOL GetClassInfo(HINSTANCE h, LPCWSTR name, LPWNDCLASSW winclass) | |
132 | { | |
133 | return GetClassInfoW(h, name, winclass); | |
134 | } | |
135 | #else | |
136 | inline BOOL GetClassInfo(HINSTANCE h, LPCSTR name, LPWNDCLASSA winclass) | |
137 | { | |
138 | return GetClassInfoA(h, name, winclass); | |
139 | } | |
140 | #endif | |
141 | #endif | |
142 | ||
143 | // LoadAccelerators | |
144 | ||
145 | #ifdef LoadAccelerators | |
146 | #undef LoadAccelerators | |
147 | #ifdef _UNICODE | |
148 | inline HACCEL LoadAccelerators(HINSTANCE h, LPCWSTR name) | |
149 | { | |
150 | return LoadAcceleratorsW(h, name); | |
151 | } | |
152 | #else | |
153 | inline HACCEL LoadAccelerators(HINSTANCE h, LPCSTR name) | |
154 | { | |
155 | return LoadAcceleratorsA(h, name); | |
156 | } | |
157 | #endif | |
158 | #endif | |
159 | ||
160 | // DrawText | |
161 | ||
162 | #ifdef DrawText | |
163 | #undef DrawText | |
164 | #ifdef _UNICODE | |
165 | inline int DrawText(HDC h, LPCWSTR str, int count, LPRECT rect, UINT format) | |
166 | { | |
167 | return DrawTextW(h, str, count, rect, format); | |
168 | } | |
169 | #else | |
170 | inline int DrawText(HDC h, LPCSTR str, int count, LPRECT rect, UINT format) | |
171 | { | |
172 | return DrawTextA(h, str, count, rect, format); | |
173 | } | |
174 | #endif | |
175 | #endif | |
176 | ||
177 | // StartDoc | |
178 | ||
179 | #ifdef StartDoc | |
180 | #undef StartDoc | |
181 | #if defined( __GNUG__ ) && !wxCHECK_W32API_VERSION( 0, 5 ) | |
182 | #define DOCINFOW DOCINFO | |
183 | #define DOCINFOA DOCINFO | |
184 | #endif | |
185 | #ifdef _UNICODE | |
186 | inline int StartDoc(HDC h, CONST DOCINFOW* info) | |
187 | { | |
188 | return StartDocW(h, (DOCINFOW*) info); | |
189 | } | |
190 | #else | |
191 | inline int StartDoc(HDC h, CONST DOCINFOA* info) | |
192 | { | |
193 | return StartDocA(h, (DOCINFOA*) info); | |
194 | } | |
195 | #endif | |
196 | #endif | |
197 | ||
198 | // GetObject | |
199 | ||
200 | #ifdef GetObject | |
201 | #undef GetObject | |
202 | inline int GetObject(HGDIOBJ h, int i, LPVOID buffer) | |
203 | { | |
204 | #ifdef _UNICODE | |
205 | return GetObjectW(h, i, buffer); | |
206 | #else | |
207 | return GetObjectA(h, i, buffer); | |
208 | #endif | |
209 | } | |
210 | #endif | |
211 | ||
212 | // GetMessage | |
213 | ||
214 | #ifdef GetMessage | |
215 | #undef GetMessage | |
216 | inline int GetMessage(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax) | |
217 | { | |
218 | #ifdef _UNICODE | |
219 | return GetMessageW(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax); | |
220 | #else | |
221 | return GetMessageA(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax); | |
222 | #endif | |
223 | } | |
224 | #endif | |
225 | ||
226 | // LoadLibrary | |
227 | ||
228 | #ifdef LoadLibrary | |
229 | #undef LoadLibrary | |
230 | #ifdef _UNICODE | |
231 | inline HINSTANCE LoadLibrary(LPCWSTR lpLibFileName) | |
232 | { | |
233 | return LoadLibraryW(lpLibFileName); | |
234 | } | |
235 | #else | |
236 | inline HINSTANCE LoadLibrary(LPCSTR lpLibFileName) | |
237 | { | |
238 | return LoadLibraryA(lpLibFileName); | |
239 | } | |
240 | #endif | |
241 | #endif | |
242 | ||
243 | // FindResource | |
244 | #ifdef FindResource | |
245 | #undef FindResource | |
246 | #ifdef _UNICODE | |
247 | inline HRSRC FindResource(HMODULE hModule, LPCWSTR lpName, LPCWSTR lpType) | |
248 | { | |
249 | return FindResourceW(hModule, lpName, lpType); | |
250 | } | |
251 | #else | |
252 | inline HRSRC FindResource(HMODULE hModule, LPCSTR lpName, LPCSTR lpType) | |
253 | { | |
254 | return FindResourceA(hModule, lpName, lpType); | |
255 | } | |
256 | #endif | |
257 | #endif | |
258 | ||
259 | // IsMaximized | |
260 | ||
261 | #ifdef IsMaximized | |
262 | #undef IsMaximized | |
263 | inline BOOL IsMaximized(HWND hwnd) | |
264 | { | |
265 | return IsZoomed(hwnd); | |
266 | } | |
267 | #endif | |
268 | ||
269 | // GetFirstChild | |
270 | ||
271 | #ifdef GetFirstChild | |
272 | #undef GetFirstChild | |
273 | inline HWND GetFirstChild(HWND hwnd) | |
274 | { | |
275 | return GetTopWindow(hwnd); | |
276 | } | |
277 | #endif | |
278 | ||
279 | // GetPrevSibling | |
280 | ||
281 | #ifdef GetPrevSibling | |
282 | #undef GetPrevSibling | |
283 | inline HWND GetPrevSibling(HWND hwnd) | |
284 | { | |
285 | return GetWindow(hwnd,GW_HWNDPREV); | |
286 | } | |
287 | #endif | |
288 | ||
289 | // GetNextSibling | |
290 | ||
291 | #ifdef GetNextSibling | |
292 | #undef GetNextSibling | |
293 | inline HWND GetNextSibling(HWND hwnd) | |
294 | { | |
295 | return GetWindow(hwnd,GW_HWNDNEXT); | |
296 | } | |
297 | #endif | |
298 | ||
299 | // For WINE | |
300 | ||
301 | #if defined(GetWindowStyle) || defined(__WXWINE__) | |
302 | #undef GetWindowStyle | |
303 | #endif | |
304 | ||
305 | // For ming and cygwin | |
306 | ||
307 | // GetFirstChild | |
308 | #ifdef GetFirstChild | |
309 | #undef GetFirstChild | |
310 | inline HWND GetFirstChild(HWND h) | |
311 | { | |
312 | return GetTopWindow(h); | |
313 | } | |
314 | #endif | |
315 | ||
316 | ||
317 | // GetNextSibling | |
318 | #ifdef GetNextSibling | |
319 | #undef GetNextSibling | |
320 | inline HWND GetNextSibling(HWND h) | |
321 | { | |
322 | return GetWindow(h, GW_HWNDNEXT); | |
323 | } | |
324 | #endif | |
325 | ||
326 | ||
327 | #ifdef Yield | |
328 | #undef Yield | |
329 | #endif | |
330 | ||
331 | // GetWindowProc | |
332 | //ifdef GetWindowProc | |
333 | // #undef GetWindowProc | |
334 | //endif | |
335 | //ifdef GetNextChild | |
336 | // #undef GetNextChild | |
337 | //endif | |
338 | ||
339 | // #endif // _WX_WINUNDEF_H_ | |
340 |