PageRenderTime 210ms CodeModel.GetById 48ms app.highlight 50ms RepoModel.GetById 104ms app.codeStats 1ms

/binding/win32/windef.d

http://github.com/wilkie/djehuty
D | 317 lines | 224 code | 70 blank | 23 comment | 2 complexity | 2a0dce7dbb882da862bc1af308d53162 MD5 | raw file
  1/*
  2 * windef.d
  3 *
  4 * This module is a port of windef.h to D.
  5 * The original copyright notice appears after this information block.
  6 *
  7 * Author: Dave Wilkinson
  8 * Originated: July 7th, 2009
  9 *
 10 */
 11
 12/****************************************************************************
 13*                                                                           *
 14* windef.h -- Basic Windows Type Definitions                                *
 15*                                                                           *
 16* Copyright (c) Microsoft Corporation. All rights reserved.                 *
 17*                                                                           *
 18****************************************************************************/
 19
 20module binding.win32.windef;
 21
 22import binding.win32.winnt;
 23
 24import binding.c;
 25
 26extern(System):
 27
 28alias Culong_t	ULONG;
 29alias ULONG*		PULONG;
 30alias ushort		USHORT;
 31alias USHORT*		PUSHORT;
 32alias ubyte		UCHAR;
 33alias UCHAR*		PUCHAR;
 34alias char*		PSZ;
 35
 36alias size_t		SIZE_T;
 37alias size_t*		PSIZE_T;
 38
 39alias ULONG	PROPID;
 40
 41const auto MAX_PATH = 260;
 42
 43enum : uint {
 44	FALSE = 0,
 45	TRUE = 1
 46}
 47
 48version(X86_64) {
 49	alias	ulong DWORD;
 50}
 51else {
 52	alias	uint DWORD;
 53}
 54
 55alias ulong DWORD64;
 56
 57alias int			BOOL;
 58alias ubyte		BYTE;
 59alias ushort		WORD;
 60alias float		FLOAT;
 61alias FLOAT*		PFLOAT;
 62alias BOOL*		PBOOL;
 63alias BOOL*		LPBOOL;
 64alias BYTE*		PBYTE;
 65alias BYTE*		LPBYTE;
 66alias int*		PINT;
 67alias int*		LPINT;
 68alias WORD*		PWORD;
 69alias WORD*		LPWORD;
 70alias Clong_t*	LPLONG;
 71alias DWORD*		PDWORD;
 72alias DWORD*		LPDWORD;
 73alias void		VOID;
 74alias void*		LPVOID;
 75alias void*		LPCVOID;
 76alias int			INT;
 77alias uint		UINT;
 78alias uint*		PUINT;
 79
 80alias long		LONG64;
 81alias long*		PLONG64;
 82alias ulong		ULONG64;
 83alias ulong*		PULONG64;
 84
 85alias Culong_t	ULONG_PTR;
 86alias Culong_t**	PULONG_PTR;
 87alias Clong_t	LONG_PTR;
 88alias Clong_t**	PLONG_PTR;
 89alias LONG_PTR	INT_PTR;
 90alias ULONG_PTR UINT_PTR;
 91alias UINT**		PUINT_PTR;
 92alias Culong_t** PDWORD_PTR;
 93alias ULONG_PTR	DWORD_PTR;
 94
 95alias ubyte	UINT8;
 96alias ushort UINT16;
 97alias uint	UINT32;
 98alias ulong	UINT64;
 99
100alias byte	INT8;
101alias short INT16;
102alias int	INT32;
103alias long	INT64;
104
105alias ulong	QWORD;
106
107alias long*		LONGLONG_PTR;
108alias ulong*		ULONGLONG_PTR;
109
110/* Types use for passing & returning polymorphic values */
111alias UINT_PTR	WPARAM;
112alias LONG_PTR	LPARAM;
113alias LONG_PTR	LRESULT;
114
115WORD MAKEWORD(WORD a, WORD b) {
116	return (cast(WORD)((cast(BYTE)(cast(DWORD_PTR)(a) & 0xff)) | (cast(WORD)(cast(BYTE)(cast(DWORD_PTR)(b) & 0xff))) << 8));
117}
118
119LONG MAKELONG(LONG a, LONG b) {
120	return (cast(LONG)((cast(WORD)(cast(DWORD_PTR)(a) & 0xffff)) | (cast(DWORD)(cast(WORD)(cast(DWORD_PTR)(b) & 0xffff))) << 16));
121}
122
123WORD LOWORD(LONG l) {
124	return (cast(WORD)(cast(DWORD_PTR)(l) & 0xffff));
125}
126
127WORD HIWORD(LONG l) {
128	return (cast(WORD)(cast(DWORD_PTR)(l) >> 16));
129}
130
131BYTE LOBYTE(WORD w) {
132	return (cast(BYTE)(cast(DWORD_PTR)(w) & 0xff));
133}
134
135BYTE HIBYTE(WORD w) {
136	return (cast(BYTE)(cast(DWORD_PTR)(w) >> 8));
137}
138
139alias WORD	ATOM;
140
141alias HANDLE*	SPHANDLE;
142alias HANDLE*	LPHANDLE;
143alias HANDLE	HGLOBAL;
144alias HANDLE	HLOCAL;
145alias HANDLE	GLOBALHANDLE;
146alias HANDLE	LOCALHANDLE;
147
148version(X86_64) {
149	alias INT_PTR function() FARPROC;
150	alias INT_PTR function() NEARPROC;
151	alias INT_PTR function() PROC;
152}
153else {
154	alias int function() FARPROC;
155	alias int function() NEARPROC;
156	alias int function() PROC;
157}
158
159alias void* HGDIOBJ;
160
161alias HANDLE HKEY;
162alias HKEY* PHKEY;
163
164alias HANDLE (HACCEL);
165
166alias HANDLE (HBITMAP);
167alias HANDLE (HBRUSH);
168
169alias HANDLE (HCOLORSPACE);
170
171alias HANDLE (HDC);
172
173alias HANDLE (HGLRC);          // OpenGL
174alias HANDLE (HDESK);
175alias HANDLE (HENHMETAFILE);
176
177alias HANDLE (HFONT);
178
179alias HANDLE (HICON);
180
181alias HANDLE (HMENU);
182
183alias HANDLE (HHOOK);
184
185alias HANDLE (HMETAFILE);
186alias HANDLE (HINSTANCE);
187alias HINSTANCE HMODULE;      /* HMODULEs can be used in place of HINSTANCEs */
188
189alias HANDLE (HPALETTE);
190alias HANDLE (HPEN);
191
192alias HANDLE (HRGN);
193alias HANDLE (HRSRC);
194alias HANDLE (HSPRITE);
195alias HANDLE (HSTR);
196alias HANDLE (HTASK);
197alias HANDLE (HWINSTA);
198alias HANDLE (HKL);
199
200alias HANDLE (HWND);
201
202alias HANDLE HWINEVENTHOOK;
203
204alias HANDLE HMONITOR;
205
206alias int HFILE;
207alias HICON HCURSOR;      /* HICONs & HCURSORs are polymorphic */
208
209alias DWORD   COLORREF;
210alias DWORD   *LPCOLORREF;
211
212const auto HFILE_ERROR = (cast(HFILE)-1);
213
214struct RECT {
215    LONG    left;
216    LONG    top;
217    LONG    right;
218    LONG    bottom;
219}
220
221alias RECT* PRECT;
222alias RECT* NPRECT;
223alias RECT* LPRECT;
224
225alias RECT* LPCRECT;
226
227struct RECTL {       /* rcl */
228    LONG    left;
229    LONG    top;
230    LONG    right;
231    LONG    bottom;
232}
233
234alias RECTL* PRECTL;
235alias RECTL* LPRECTL;
236
237alias RECTL* LPCRECTL;
238
239struct POINT {
240    LONG  x;
241    LONG  y;
242}
243
244alias POINT* PPOINT;
245alias POINT* NPPOINT;
246alias POINT* LPPOINT;
247
248struct POINTL {    /* ptl  */
249    LONG  x;
250    LONG  y;
251}
252
253alias POINTL* PPOINTL;
254alias POINTL* LPPOINTL;
255
256struct SIZE {
257    LONG        cx;
258    LONG        cy;
259}
260
261alias SIZE* PSIZE;
262alias SIZE* LPSIZE;
263
264alias SIZE SIZEL;
265alias SIZE* PSIZEL;
266alias SIZE* LPSIZEL;
267
268struct POINTS {
269    SHORT   y;
270    SHORT   x;
271}
272
273alias POINTS* PPOINTS;
274alias POINTS* LPPOINTS;
275
276//
277//  File System time stamps are represented with the following structure:
278//
279
280struct FILETIME {
281    DWORD dwLowDateTime;
282    DWORD dwHighDateTime;
283}
284
285alias FILETIME* PFILETIME;
286alias FILETIME* LPFILETIME;
287
288/* mode selections for the device mode function */
289const auto DM_UPDATE           = 1;
290const auto DM_COPY             = 2;
291const auto DM_PROMPT           = 4;
292const auto DM_MODIFY           = 8;
293
294const auto DM_IN_BUFFER        = DM_MODIFY;
295const auto DM_IN_PROMPT        = DM_PROMPT;
296const auto DM_OUT_BUFFER       = DM_COPY;
297const auto DM_OUT_DEFAULT      = DM_UPDATE;
298
299/* device capabilities indices */
300const auto DC_FIELDS           = 1;
301const auto DC_PAPERS           = 2;
302const auto DC_PAPERSIZE        = 3;
303const auto DC_MINEXTENT        = 4;
304const auto DC_MAXEXTENT        = 5;
305const auto DC_BINS             = 6;
306const auto DC_DUPLEX           = 7;
307const auto DC_SIZE             = 8;
308const auto DC_EXTRA            = 9;
309const auto DC_VERSION          = 10;
310const auto DC_DRIVER           = 11;
311const auto DC_BINNAMES         = 12;
312const auto DC_ENUMRESOLUTIONS  = 13;
313const auto DC_FILEDEPENDENCIES = 14;
314const auto DC_TRUETYPE         = 15;
315const auto DC_PAPERNAMES       = 16;
316const auto DC_ORIENTATION      = 17;
317const auto DC_COPIES           = 18;