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