While dragging, catch keyboard messages between WM_KEYFIRST and
[wine.git] / include / windef.h
blobe36f3a32a7da5b3d511396c5100c8134e613a0ac
1 /*
2 * Basic types definitions
4 * Copyright 1996 Alexandre Julliard
5 */
7 #ifndef __WINE_WINDEF_H
8 #define __WINE_WINDEF_H
10 #ifdef __WINE__
11 # include "config.h"
12 # undef UNICODE
13 #endif /* __WINE__ */
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
19 /* Misc. constants. */
21 #ifdef FALSE
22 #undef FALSE
23 #endif
24 #define FALSE 0
26 #ifdef TRUE
27 #undef TRUE
28 #endif
29 #define TRUE 1
31 #ifdef NULL
32 #undef NULL
33 #endif
34 #define NULL 0
36 /* Macros to map Winelib names to the correct implementation name */
37 /* depending on __WINE__ and UNICODE macros. */
38 /* Note that Winelib is purely Win32. */
40 #ifdef __WINE__
41 # define WINELIB_NAME_AW(func) \
42 func##_must_be_suffixed_with_W_or_A_in_this_context \
43 func##_must_be_suffixed_with_W_or_A_in_this_context
44 #else /* __WINE__ */
45 # ifdef UNICODE
46 # define WINELIB_NAME_AW(func) func##W
47 # else
48 # define WINELIB_NAME_AW(func) func##A
49 # endif /* UNICODE */
50 #endif /* __WINE__ */
52 #ifdef __WINE__
53 # define DECL_WINELIB_TYPE_AW(type) /* nothing */
54 #else /* __WINE__ */
55 # define DECL_WINELIB_TYPE_AW(type) typedef WINELIB_NAME_AW(type) type;
56 #endif /* __WINE__ */
58 #ifndef NONAMELESSSTRUCT
59 # if defined(__WINE__) || !defined(_FORCENAMELESSSTRUCT)
60 # define NONAMELESSSTRUCT
61 # endif
62 #endif /* !defined(NONAMELESSSTRUCT) */
64 #ifndef NONAMELESSUNION
65 # if defined(__WINE__) || !defined(_FORCENAMELESSUNION) || !defined(__cplusplus)
66 # define NONAMELESSUNION
67 # endif
68 #endif /* !defined(NONAMELESSUNION) */
70 #ifndef NONAMELESSSTRUCT
71 #define DUMMYSTRUCTNAME
72 #define DUMMYSTRUCTNAME1
73 #define DUMMYSTRUCTNAME2
74 #define DUMMYSTRUCTNAME3
75 #define DUMMYSTRUCTNAME4
76 #define DUMMYSTRUCTNAME5
77 #else /* !defined(NONAMELESSSTRUCT) */
78 #define DUMMYSTRUCTNAME s
79 #define DUMMYSTRUCTNAME1 s1
80 #define DUMMYSTRUCTNAME2 s2
81 #define DUMMYSTRUCTNAME3 s3
82 #define DUMMYSTRUCTNAME4 s4
83 #define DUMMYSTRUCTNAME5 s5
84 #endif /* !defined(NONAMELESSSTRUCT) */
86 #ifndef NONAMELESSUNION
87 #define DUMMYUNIONNAME
88 #define DUMMYUNIONNAME1
89 #define DUMMYUNIONNAME2
90 #define DUMMYUNIONNAME3
91 #define DUMMYUNIONNAME4
92 #define DUMMYUNIONNAME5
93 #define DUMMYUNIONNAME6
94 #define DUMMYUNIONNAME7
95 #define DUMMYUNIONNAME8
96 #else /* !defined(NONAMELESSUNION) */
97 #define DUMMYUNIONNAME u
98 #define DUMMYUNIONNAME1 u1
99 #define DUMMYUNIONNAME2 u2
100 #define DUMMYUNIONNAME3 u3
101 #define DUMMYUNIONNAME4 u4
102 #define DUMMYUNIONNAME5 u5
103 #define DUMMYUNIONNAME6 u6
104 #define DUMMYUNIONNAME7 u7
105 #define DUMMYUNIONNAME8 u8
106 #endif /* !defined(NONAMELESSUNION) */
108 /* Calling conventions definitions */
110 #ifdef __i386__
111 # ifndef _X86_
112 # define _X86_
113 # endif
114 # if defined(__GNUC__) && ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)))
115 # define __stdcall __attribute__((__stdcall__))
116 # define __cdecl __attribute__((__cdecl__))
117 # define __RESTORE_ES __asm__ __volatile__("pushl %ds\n\tpopl %es")
118 # else
119 # error You need gcc >= 2.7 to build Wine on a 386
120 # endif /* __GNUC__ */
121 #else /* __i386__ */
122 # define __stdcall
123 # define __cdecl
124 # define __RESTORE_ES
125 #endif /* __i386__ */
127 #define CALLBACK __stdcall
128 #define WINAPI __stdcall
129 #define APIPRIVATE __stdcall
130 #define PASCAL __stdcall
131 #define pascal __stdcall
132 #define _pascal __stdcall
133 #define _stdcall __stdcall
134 #define _fastcall __stdcall
135 #define __fastcall __stdcall
136 #define __export __stdcall
137 #define CDECL __cdecl
138 #define _CDECL __cdecl
139 #define cdecl __cdecl
140 #define _cdecl __cdecl
141 #define WINAPIV __cdecl
142 #define APIENTRY WINAPI
144 #define __declspec(x)
145 #define dllimport
146 #define dllexport
148 #define CONST const
150 /* Standard data types. These are the same for emulator and library. */
152 typedef void VOID;
153 typedef int INT;
154 typedef unsigned int UINT;
155 typedef unsigned short WORD;
156 typedef unsigned long DWORD;
157 typedef unsigned long ULONG;
158 typedef unsigned char BYTE;
159 typedef long LONG;
160 typedef short SHORT;
161 typedef unsigned short USHORT;
162 typedef char CHAR;
163 typedef unsigned char UCHAR;
164 /* Some systems might have wchar_t, but we really need 16 bit characters */
165 typedef unsigned short WCHAR;
166 typedef int BOOL;
167 typedef double DATE;
168 typedef double DOUBLE;
170 /* FIXME: Wine does not compile with strict on, therefore strict
171 * handles are presently only usable on machines where sizeof(UINT) ==
172 * sizeof(void*). HANDLEs are supposed to be void* but a large amount
173 * of WINE code operates on HANDLES as if they are UINTs. So to WINE
174 * they exist as UINTs but to the Winelib user who turns on strict,
175 * they exist as void*. If there is a size difference between UINT and
176 * void* then things get ugly. */
177 #ifdef STRICT
178 typedef VOID* HANDLE;
179 #else
180 typedef UINT HANDLE;
181 #endif
184 typedef HANDLE *LPHANDLE;
186 /* Integer types. These are the same for emulator and library. */
187 typedef UINT WPARAM;
188 typedef LONG LPARAM;
189 typedef LONG HRESULT;
190 typedef LONG LRESULT;
191 typedef WORD ATOM;
192 typedef WORD CATCHBUF[9];
193 typedef WORD *LPCATCHBUF;
194 typedef HANDLE HHOOK;
195 typedef HANDLE HMONITOR;
196 typedef DWORD LCID;
197 typedef WORD LANGID;
198 typedef DWORD LCTYPE;
199 typedef float FLOAT;
201 /* Pointers types. These are the same for emulator and library. */
202 /* winnt types */
203 typedef VOID *PVOID;
204 typedef const void *PCVOID;
205 typedef CHAR *PCHAR;
206 typedef UCHAR *PUCHAR;
207 typedef BYTE *PBYTE;
208 typedef WORD *PWORD;
209 typedef USHORT *PUSHORT;
210 typedef SHORT *PSHORT;
211 typedef ULONG *PULONG;
212 typedef LONG *PLONG;
213 typedef DWORD *PDWORD;
214 /* common win32 types */
215 typedef CHAR *LPSTR;
216 typedef CHAR *PSTR;
217 typedef const CHAR *LPCSTR;
218 typedef const CHAR *PCSTR;
219 typedef WCHAR *LPWSTR;
220 typedef WCHAR *PWSTR;
221 typedef const WCHAR *LPCWSTR;
222 typedef const WCHAR *PCWSTR;
223 typedef BYTE *LPBYTE;
224 typedef WORD *LPWORD;
225 typedef DWORD *LPDWORD;
226 typedef LONG *LPLONG;
227 typedef VOID *LPVOID;
228 typedef const VOID *LPCVOID;
229 typedef INT *PINT;
230 typedef INT *LPINT;
231 typedef UINT *PUINT;
232 typedef UINT *LPUINT;
233 typedef FLOAT *PFLOAT;
234 typedef FLOAT *LPFLOAT;
235 typedef BOOL *PBOOL;
236 typedef BOOL *LPBOOL;
238 /* Special case: a segmented pointer is just a pointer in the user's code. */
240 #ifdef __WINE__
241 typedef DWORD SEGPTR;
242 #else
243 typedef void* SEGPTR;
244 #endif /* __WINE__ */
246 /* Handle types that exist both in Win16 and Win32. */
248 #ifdef STRICT
249 #define DECLARE_HANDLE(a) \
250 typedef struct a##__ { int unused; } *a; \
251 typedef a *P##a; \
252 typedef a *LP##a
253 #else /*STRICT*/
254 #define DECLARE_HANDLE(a) \
255 typedef HANDLE a; \
256 typedef a *P##a; \
257 typedef a *LP##a
258 #endif /*STRICT*/
260 DECLARE_HANDLE(HACMDRIVERID);
261 DECLARE_HANDLE(HACMDRIVER);
262 DECLARE_HANDLE(HACMOBJ);
263 DECLARE_HANDLE(HACMSTREAM);
264 DECLARE_HANDLE(HMETAFILEPICT);
266 DECLARE_HANDLE(HACCEL);
267 DECLARE_HANDLE(HBITMAP);
268 DECLARE_HANDLE(HBRUSH);
269 DECLARE_HANDLE(HCOLORSPACE);
270 DECLARE_HANDLE(HCURSOR);
271 DECLARE_HANDLE(HDC);
272 DECLARE_HANDLE(HDROP);
273 DECLARE_HANDLE(HDRVR);
274 DECLARE_HANDLE(HDWP);
275 DECLARE_HANDLE(HENHMETAFILE);
276 DECLARE_HANDLE(HFILE);
277 DECLARE_HANDLE(HFONT);
278 DECLARE_HANDLE(HICON);
279 DECLARE_HANDLE(HINSTANCE);
280 DECLARE_HANDLE(HKEY);
281 DECLARE_HANDLE(HMENU);
282 DECLARE_HANDLE(HMETAFILE);
283 DECLARE_HANDLE(HMIDI);
284 DECLARE_HANDLE(HMIDIIN);
285 DECLARE_HANDLE(HMIDIOUT);
286 DECLARE_HANDLE(HMIDISTRM);
287 DECLARE_HANDLE(HMIXER);
288 DECLARE_HANDLE(HMIXEROBJ);
289 DECLARE_HANDLE(HMMIO);
290 DECLARE_HANDLE(HPALETTE);
291 DECLARE_HANDLE(HPEN);
292 DECLARE_HANDLE(HQUEUE);
293 DECLARE_HANDLE(HRGN);
294 DECLARE_HANDLE(HRSRC);
295 DECLARE_HANDLE(HTASK);
296 DECLARE_HANDLE(HWAVE);
297 DECLARE_HANDLE(HWAVEIN);
298 DECLARE_HANDLE(HWAVEOUT);
299 DECLARE_HANDLE(HWINSTA);
300 DECLARE_HANDLE(HDESK);
301 DECLARE_HANDLE(HWND);
302 DECLARE_HANDLE(HKL);
303 DECLARE_HANDLE(HRASCONN);
305 /* Handle types that must remain interchangeable even with strict on */
307 typedef HINSTANCE HMODULE;
308 typedef HANDLE HGDIOBJ;
309 typedef HANDLE HGLOBAL;
310 typedef HANDLE HLOCAL;
311 typedef HANDLE GLOBALHANDLE;
312 typedef HANDLE LOCALHANDLE;
314 /* Callback function pointers types */
316 typedef BOOL CALLBACK (*DATEFMT_ENUMPROCA)(LPSTR);
317 typedef BOOL CALLBACK (*DATEFMT_ENUMPROCW)(LPWSTR);
318 DECL_WINELIB_TYPE_AW(DATEFMT_ENUMPROC)
319 typedef BOOL CALLBACK (*DLGPROC)(HWND,UINT,WPARAM,LPARAM);
320 typedef LRESULT CALLBACK (*DRIVERPROC)(DWORD,HDRVR,UINT,LPARAM,LPARAM);
321 typedef INT CALLBACK (*EDITWORDBREAKPROCA)(LPSTR,INT,INT,INT);
322 typedef INT CALLBACK (*EDITWORDBREAKPROCW)(LPWSTR,INT,INT,INT);
323 DECL_WINELIB_TYPE_AW(EDITWORDBREAKPROC)
324 typedef LRESULT CALLBACK (*FARPROC)();
325 typedef INT CALLBACK (*PROC)();
326 typedef BOOL CALLBACK (*GRAYSTRINGPROC)(HDC,LPARAM,INT);
327 typedef LRESULT CALLBACK (*HOOKPROC)(INT,WPARAM,LPARAM);
328 typedef BOOL CALLBACK (*PROPENUMPROCA)(HWND,LPCSTR,HANDLE);
329 typedef BOOL CALLBACK (*PROPENUMPROCW)(HWND,LPCWSTR,HANDLE);
330 DECL_WINELIB_TYPE_AW(PROPENUMPROC)
331 typedef BOOL CALLBACK (*PROPENUMPROCEXA)(HWND,LPCSTR,HANDLE,LPARAM);
332 typedef BOOL CALLBACK (*PROPENUMPROCEXW)(HWND,LPCWSTR,HANDLE,LPARAM);
333 DECL_WINELIB_TYPE_AW(PROPENUMPROCEX)
334 typedef BOOL CALLBACK (*TIMEFMT_ENUMPROCA)(LPSTR);
335 typedef BOOL CALLBACK (*TIMEFMT_ENUMPROCW)(LPWSTR);
336 DECL_WINELIB_TYPE_AW(TIMEFMT_ENUMPROC)
337 typedef VOID CALLBACK (*TIMERPROC)(HWND,UINT,UINT,DWORD);
338 typedef BOOL CALLBACK (*WNDENUMPROC)(HWND,LPARAM);
339 typedef LRESULT CALLBACK (*WNDPROC)(HWND,UINT,WPARAM,LPARAM);
341 /*----------------------------------------------------------------------------
342 ** FIXME: Better isolate Wine's reliance on the xxx16 type definitions.
343 ** For now, we just isolate them to make the situation clear.
344 **--------------------------------------------------------------------------*/
345 #include "wine/windef16.h"
347 /* Define some empty macros for compatibility with Windows code. */
349 #ifndef __WINE__
350 #define NEAR
351 #define FAR
352 #define near
353 #define far
354 #define _near
355 #define _far
356 #define IN
357 #define OUT
358 #define OPTIONAL
359 #endif /* __WINE__ */
361 /* Macro for structure packing. */
363 #ifdef __GNUC__
364 #define WINE_PACKED __attribute__((packed))
365 #define WINE_UNUSED __attribute__((unused))
366 #define WINE_NORETURN __attribute__((noreturn))
367 #else
368 #define WINE_PACKED /* nothing */
369 #define WINE_UNUSED /* nothing */
370 #define WINE_NORETURN /* nothing */
371 #endif
373 /* Macros to split words and longs. */
375 #define LOBYTE(w) ((BYTE)(WORD)(w))
376 #define HIBYTE(w) ((BYTE)((WORD)(w) >> 8))
378 #define LOWORD(l) ((WORD)(DWORD)(l))
379 #define HIWORD(l) ((WORD)((DWORD)(l) >> 16))
381 #define SLOWORD(l) ((INT16)(LONG)(l))
382 #define SHIWORD(l) ((INT16)((LONG)(l) >> 16))
384 #define MAKEWORD(low,high) ((WORD)(((BYTE)(low)) | ((WORD)((BYTE)(high))) << 8))
385 #define MAKELONG(low,high) ((LONG)(((WORD)(low)) | (((DWORD)((WORD)(high))) << 16)))
386 #define MAKELPARAM(low,high) ((LPARAM)MAKELONG(low,high))
387 #define MAKEWPARAM(low,high) ((WPARAM)MAKELONG(low,high))
388 #define MAKELRESULT(low,high) ((LRESULT)MAKELONG(low,high))
389 #define MAKEINTATOM(atom) ((LPCSTR)MAKELONG((atom),0))
391 #define SELECTOROF(ptr) (HIWORD(ptr))
392 #define OFFSETOF(ptr) (LOWORD(ptr))
394 #ifdef __WINE__
395 /* macros to set parts of a DWORD (not in the Windows API) */
396 #define SET_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD(val))
397 #define SET_LOBYTE(dw,val) ((dw) = ((dw) & 0xffffff00) | LOBYTE(val))
398 #define SET_HIBYTE(dw,val) ((dw) = ((dw) & 0xffff00ff) | (LOWORD(val) & 0xff00))
399 #define ADD_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD((DWORD)(dw)+(val)))
400 #endif
402 /* Macros to access unaligned or wrong-endian WORDs and DWORDs. */
403 /* Note: These macros are semantically broken, at least for wrc. wrc
404 spits out data in the platform's current binary format, *not* in
405 little-endian format. These macros are used throughout the resource
406 code to load and store data to the resources. Since it is unlikely
407 that we'll ever be dealing with little-endian resource data, the
408 byte-swapping nature of these macros has been disabled. Rather than
409 remove the use of these macros from the resource loading code, the
410 macros have simply been disabled. In the future, someone may want
411 to reactivate these macros for other purposes. In that case, the
412 resource code will have to be modified to use different macros. */
414 #if 1
415 #define PUT_WORD(ptr,w) (*(WORD *)(ptr) = (w))
416 #define GET_WORD(ptr) (*(WORD *)(ptr))
417 #define PUT_DWORD(ptr,dw) (*(DWORD *)(ptr) = (dw))
418 #define GET_DWORD(ptr) (*(DWORD *)(ptr))
419 #else
420 #define PUT_WORD(ptr,w) (*(BYTE *)(ptr) = LOBYTE(w), \
421 *((BYTE *)(ptr) + 1) = HIBYTE(w))
422 #define GET_WORD(ptr) ((WORD)(*(BYTE *)(ptr) | \
423 (WORD)(*((BYTE *)(ptr)+1) << 8)))
424 #define PUT_DWORD(ptr,dw) (PUT_WORD((ptr),LOWORD(dw)), \
425 PUT_WORD((WORD *)(ptr)+1,HIWORD(dw)))
426 #define GET_DWORD(ptr) ((DWORD)(GET_WORD(ptr) | \
427 ((DWORD)GET_WORD((WORD *)(ptr)+1) << 16)))
428 #endif /* 1 */
430 /* min and max macros */
431 #define __max(a,b) (((a) > (b)) ? (a) : (b))
432 #define __min(a,b) (((a) < (b)) ? (a) : (b))
433 #ifndef max
434 #define max(a,b) (((a) > (b)) ? (a) : (b))
435 #endif
436 #ifndef min
437 #define min(a,b) (((a) < (b)) ? (a) : (b))
438 #endif
440 #define _MAX_PATH 260
441 #define MAX_PATH 260
442 #define _MAX_DRIVE 3
443 #define _MAX_DIR 256
444 #define _MAX_FNAME 255
445 #define _MAX_EXT 256
447 #define HFILE_ERROR16 ((HFILE16)-1)
448 #define HFILE_ERROR ((HFILE)-1)
450 /* The SIZE structure */
451 typedef struct tagSIZE
453 INT cx;
454 INT cy;
455 } SIZE, *PSIZE, *LPSIZE;
458 typedef SIZE SIZEL, *PSIZEL, *LPSIZEL;
460 #define CONV_SIZE16TO32(s16,s32) \
461 ((s32)->cx = (INT)(s16)->cx, (s32)->cy = (INT)(s16)->cy)
462 #define CONV_SIZE32TO16(s32,s16) \
463 ((s16)->cx = (INT16)(s32)->cx, (s16)->cy = (INT16)(s32)->cy)
465 /* The POINT structure */
466 typedef struct tagPOINT
468 LONG x;
469 LONG y;
470 } POINT, *PPOINT, *LPPOINT;
472 typedef struct _POINTL
474 LONG x;
475 LONG y;
476 } POINTL;
478 #define CONV_POINT16TO32(p16,p32) \
479 ((p32)->x = (INT)(p16)->x, (p32)->y = (INT)(p16)->y)
480 #define CONV_POINT32TO16(p32,p16) \
481 ((p16)->x = (INT16)(p32)->x, (p16)->y = (INT16)(p32)->y)
483 #define MAKEPOINT16(l) (*((POINT16 *)&(l)))
485 /* The POINTS structure */
487 typedef struct tagPOINTS
489 SHORT x;
490 SHORT y;
491 } POINTS, *PPOINTS, *LPPOINTS;
494 #define MAKEPOINTS(l) (*((POINTS *)&(l)))
497 /* The RECT structure */
498 typedef struct tagRECT
500 INT left;
501 INT top;
502 INT right;
503 INT bottom;
504 } RECT, *PRECT, *LPRECT;
505 typedef const RECT *LPCRECT;
508 typedef struct tagRECTL
510 LONG left;
511 LONG top;
512 LONG right;
513 LONG bottom;
514 } RECTL, *PRECTL, *LPRECTL;
516 typedef const RECTL *LPCRECTL;
518 #define CONV_RECT16TO32(r16,r32) \
519 ((r32)->left = (INT)(r16)->left, (r32)->top = (INT)(r16)->top, \
520 (r32)->right = (INT)(r16)->right, (r32)->bottom = (INT)(r16)->bottom)
521 #define CONV_RECT32TO16(r32,r16) \
522 ((r16)->left = (INT16)(r32)->left, (r16)->top = (INT16)(r32)->top, \
523 (r16)->right = (INT16)(r32)->right, (r16)->bottom = (INT16)(r32)->bottom)
525 #ifdef __cplusplus
527 #endif
529 #endif /* __WINE_WINDEF_H */