windef.h 8.24 KB
Newer Older
1 2 3 4
/*
 * Basic types definitions
 *
 * Copyright 1996 Alexandre Julliard
5 6 7 8 9 10 11 12 13 14 15 16 17 18
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
 */
20

21 22
#ifndef _WINDEF_
#define _WINDEF_
23

24
#ifndef WINVER
25
#define WINVER 0x0500
26
#endif
27

28 29 30 31 32 33
#ifndef NO_STRICT
# ifndef STRICT
#  define STRICT
# endif /* STRICT */
#endif /* NO_STRICT */

34 35 36 37 38 39
#ifdef __cplusplus
extern "C" {
#endif

/* Calling conventions definitions */

40 41 42 43
#if defined(__i386__) && !defined(_X86_)
# define _X86_
#endif

44 45 46 47
#if defined(_X86_) && !defined(__i386__)
# define __i386__
#endif

48 49 50 51
#ifdef __x86_64__
#define _WIN64
#endif

52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
#ifndef __stdcall
# ifdef __i386__
#  ifdef __GNUC__
#   define __stdcall __attribute__((__stdcall__))
#  elif defined(_MSC_VER)
    /* Nothing needs to be done. __stdcall already exists */
#  else
#   error You need to define __stdcall for your compiler
#  endif
# else  /* __i386__ */
#  define __stdcall
# endif  /* __i386__ */
#endif /* __stdcall */

#ifndef __cdecl
# if defined(__i386__) && defined(__GNUC__)
#  define __cdecl __attribute__((__cdecl__))
# elif !defined(_MSC_VER)
#  define __cdecl
71
# endif
72
#endif /* __cdecl */
73

74 75 76 77 78
#ifdef __WINESRC__
#define __ONLY_IN_WINELIB(x)	do_not_use_this_in_wine
#else
#define __ONLY_IN_WINELIB(x)	x
#endif
79 80

#ifndef pascal
81
#define pascal      __ONLY_IN_WINELIB(__stdcall)
82 83
#endif
#ifndef _pascal
84
#define _pascal	    __ONLY_IN_WINELIB(__stdcall)
85 86
#endif
#ifndef _stdcall
87
#define _stdcall    __ONLY_IN_WINELIB(__stdcall)
88 89
#endif
#ifndef _fastcall
90
#define _fastcall   __ONLY_IN_WINELIB(__stdcall)
91 92
#endif
#ifndef __fastcall
93
#define __fastcall  __ONLY_IN_WINELIB(__stdcall)
94 95
#endif
#ifndef __export
96
#define __export    __ONLY_IN_WINELIB(__stdcall)
97 98
#endif
#ifndef cdecl
99
#define cdecl       __ONLY_IN_WINELIB(__cdecl)
100 101
#endif
#ifndef _cdecl
102
#define _cdecl      __ONLY_IN_WINELIB(__cdecl)
103 104 105
#endif

#ifndef near
106
#define near        __ONLY_IN_WINELIB(/* nothing */)
107 108
#endif
#ifndef far
109
#define far         __ONLY_IN_WINELIB(/* nothing */)
110 111
#endif
#ifndef _near
112
#define _near       __ONLY_IN_WINELIB(/* nothing */)
113 114
#endif
#ifndef _far
115
#define _far        __ONLY_IN_WINELIB(/* nothing */)
116 117
#endif
#ifndef NEAR
118
#define NEAR        __ONLY_IN_WINELIB(/* nothing */)
119 120
#endif
#ifndef FAR
121
#define FAR         __ONLY_IN_WINELIB(/* nothing */)
122 123
#endif

124 125
#ifndef _MSC_VER
# ifndef _declspec
126
#  define _declspec(x)    __ONLY_IN_WINELIB(/* nothing */)
127 128
# endif
# ifndef __declspec
129
#  define __declspec(x)   __ONLY_IN_WINELIB(/* nothing */)
130
# endif
131 132
#endif

133 134 135 136
#ifdef _MSC_VER
# define inline __inline
#endif

137 138 139 140 141 142 143 144 145
#define CALLBACK    __stdcall
#define WINAPI      __stdcall
#define APIPRIVATE  __stdcall
#define PASCAL      __stdcall
#define CDECL       __cdecl
#define _CDECL      __cdecl
#define WINAPIV     __cdecl
#define APIENTRY    WINAPI
#define CONST       const
146

147
/* Misc. constants. */
148

149
#undef NULL
150
#ifdef __cplusplus
151 152 153 154 155 156 157
#define NULL  0
#else
#define NULL  ((void*)0)
#endif

#ifdef FALSE
#undef FALSE
158
#endif
159
#define FALSE 0
160

161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
#ifdef TRUE
#undef TRUE
#endif
#define TRUE  1

#ifndef IN
#define IN
#endif

#ifndef OUT
#define OUT
#endif

#ifndef OPTIONAL
#define OPTIONAL
#endif

/* Standard data types */

typedef void                                   *LPVOID;
typedef const void                             *LPCVOID;
typedef int             BOOL,       *PBOOL,    *LPBOOL;
typedef unsigned char   BYTE,       *PBYTE,    *LPBYTE;
typedef unsigned char   UCHAR,      *PUCHAR;
typedef unsigned short  WORD,       *PWORD,    *LPWORD;
typedef unsigned short  USHORT,     *PUSHORT;
typedef int             INT,        *PINT,     *LPINT;
typedef unsigned int    UINT,       *PUINT;
189 190 191 192 193 194 195
typedef float           FLOAT,      *PFLOAT;
typedef char                        *PSZ;
#if defined(_WIN64) && !defined(_MSC_VER)
typedef int                                    *LPLONG;
typedef unsigned int    DWORD,      *PDWORD,   *LPDWORD;
typedef unsigned int    ULONG,      *PULONG;
#else
196 197 198
typedef long                                   *LPLONG;
typedef unsigned long   DWORD,      *PDWORD,   *LPDWORD;
typedef unsigned long   ULONG,      *PULONG;
199
#endif
200

201 202 203
/* Macros to map Winelib names to the correct implementation name */
/* Note that Winelib is purely Win32.                             */

204
#ifdef __WINESRC__
205 206 207 208
#define WINE_NO_UNICODE_MACROS
#endif

#ifdef WINE_NO_UNICODE_MACROS
209 210 211
# define WINELIB_NAME_AW(func) \
    func##_must_be_suffixed_with_W_or_A_in_this_context \
    func##_must_be_suffixed_with_W_or_A_in_this_context
212
#else  /* WINE_NO_UNICODE_MACROS */
213 214 215 216
# ifdef UNICODE
#  define WINELIB_NAME_AW(func) func##W
# else
#  define WINELIB_NAME_AW(func) func##A
217 218
# endif
#endif  /* WINE_NO_UNICODE_MACROS */
219

220
#ifdef WINE_NO_UNICODE_MACROS
221
# define DECL_WINELIB_TYPE_AW(type)  /* nothing */
222
#else
223
# define DECL_WINELIB_TYPE_AW(type)  typedef WINELIB_NAME_AW(type) type;
224
#endif
225

226
#include <winnt.h>
227

228 229 230 231 232 233
/* Polymorphic types */

typedef UINT_PTR        WPARAM;
typedef LONG_PTR        LPARAM;
typedef LONG_PTR        LRESULT;

234
/* Integer types */
235

236
typedef WORD            ATOM;
237 238
typedef DWORD           COLORREF, *LPCOLORREF;

239

240
/* Handle types */
241

242
typedef int HFILE;
243
DECLARE_HANDLE(HACCEL);
244 245
DECLARE_HANDLE(HBITMAP);
DECLARE_HANDLE(HBRUSH);
246
DECLARE_HANDLE(HCOLORSPACE);
247
DECLARE_HANDLE(HDC);
248
DECLARE_HANDLE(HDESK);
249
DECLARE_HANDLE(HENHMETAFILE);
250
DECLARE_HANDLE(HFONT);
251
DECLARE_HANDLE(HGLRC);
252
DECLARE_HANDLE(HHOOK);
253
DECLARE_HANDLE(HICON);
254
DECLARE_HANDLE(HINSTANCE);
255
DECLARE_HANDLE(HKEY);
256
typedef HKEY *PHKEY;
257
DECLARE_HANDLE(HKL);
258
DECLARE_HANDLE(HMENU);
259
DECLARE_HANDLE(HMETAFILE);
260
DECLARE_HANDLE(HMONITOR);
261
DECLARE_HANDLE(HPALETTE);
262 263
DECLARE_HANDLE(HPEN);
DECLARE_HANDLE(HRGN);
264
DECLARE_HANDLE(HRSRC);
265
DECLARE_HANDLE(HTASK);
266
DECLARE_HANDLE(HWINEVENTHOOK);
267
DECLARE_HANDLE(HWINSTA);
268
DECLARE_HANDLE(HWND);
269

270 271 272 273 274 275
/* Handle types that must remain interchangeable even with strict on */

typedef HINSTANCE HMODULE;
typedef HANDLE HGDIOBJ;
typedef HANDLE HGLOBAL;
typedef HANDLE HLOCAL;
276 277
typedef HANDLE GLOBALHANDLE;
typedef HANDLE LOCALHANDLE;
278
typedef HICON HCURSOR;
279

280 281
/* Callback function pointers types */

282 283
typedef INT     (CALLBACK *FARPROC)();
typedef INT     (CALLBACK *PROC)();
284

285

286 287
/* Macros to split words and longs. */

288 289
#define LOBYTE(w)              ((BYTE)((DWORD_PTR)(w) & 0xFF))
#define HIBYTE(w)              ((BYTE)((DWORD_PTR)(w) >> 8))
290

291 292
#define LOWORD(l)              ((WORD)((DWORD_PTR)(l) & 0xFFFF))
#define HIWORD(l)              ((WORD)((DWORD_PTR)(l) >> 16))
293

294 295
#define MAKEWORD(low,high)     ((WORD)(((BYTE)((DWORD_PTR)(low) & 0xFF)) | ((WORD)((BYTE)((DWORD_PTR)(high) & 0xFF))) << 8))
#define MAKELONG(low,high)     ((LONG)(((WORD)((DWORD_PTR)(low) & 0xFFFF)) | ((DWORD)((WORD)((DWORD_PTR)(high) & 0xFFFF))) << 16))
296

297
/* min and max macros */
298
#ifndef NOMINMAX
299
#ifndef max
300
#define max(a,b)   (((a) > (b)) ? (a) : (b))
301 302
#endif
#ifndef min
303
#define min(a,b)   (((a) < (b)) ? (a) : (b))
304
#endif
305
#endif  /* NOMINMAX */
306

307 308 309 310
#ifdef MAX_PATH /* Work-around for Mingw */ 
#undef MAX_PATH
#endif /* MAX_PATH */

311
#define MAX_PATH        260
312
#define HFILE_ERROR     ((HFILE)-1)
313

314 315 316
/* The SIZE structure */
typedef struct tagSIZE
{
317 318
    LONG cx;
    LONG cy;
319 320 321 322 323 324 325 326 327 328
} SIZE, *PSIZE, *LPSIZE;

typedef SIZE SIZEL, *PSIZEL, *LPSIZEL;

/* The POINT structure */
typedef struct tagPOINT
{
    LONG  x;
    LONG  y;
} POINT, *PPOINT, *LPPOINT;
329 330 331

typedef struct _POINTL
{
332 333
    LONG x;
    LONG y;
334
} POINTL, *PPOINTL;
335

336 337 338 339
/* The POINTS structure */

typedef struct tagPOINTS
{
340 341 342 343
#ifdef WORDS_BIGENDIAN
    SHORT y;
    SHORT x;
#else
344 345
    SHORT x;
    SHORT y;
346
#endif
347 348 349 350 351
} POINTS, *PPOINTS, *LPPOINTS;

/* The RECT structure */
typedef struct tagRECT
{
352 353 354 355
    LONG left;
    LONG top;
    LONG right;
    LONG bottom;
356 357 358
} RECT, *PRECT, *LPRECT;
typedef const RECT *LPCRECT;

359
typedef struct _RECTL
360 361
{
    LONG left;
362
    LONG top;
363 364 365 366 367 368 369 370 371
    LONG right;
    LONG bottom;
} RECTL, *PRECTL, *LPRECTL;

typedef const RECTL *LPCRECTL;

#ifdef __cplusplus
}
#endif
372

373
#endif /* _WINDEF_ */