1 /**
2  * Windows API header module
3  *
4  * Translated from MinGW Windows headers
5  *
6  * Authors: Stewart Gordon
7  * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
8  * Source: $(DRUNTIMESRC core/sys/windows/_windef.d)
9  */
10 module core.sys.windows.windef;
11 version (Windows):
12 
13 public import core.sys.windows.winnt;
14 import core.sys.windows.w32api;
15 
16 enum size_t MAX_PATH = 260;
17 
18 pure nothrow @nogc {
19     ushort MAKEWORD(ubyte a, ubyte b) {
20         return cast(ushort) ((b << 8) | a);
21     }
22 
23     ushort MAKEWORD(ushort a, ushort b) {
24         assert((a & 0xFF00) == 0);
25         assert((b & 0xFF00) == 0);
26         return MAKEWORD(cast(ubyte)a, cast(ubyte)b);
27     }
28 
29     uint MAKELONG(ushort a, ushort b) {
30         return cast(uint) ((b << 16) | a);
31     }
32 
33     uint MAKELONG(uint a, uint b) {
34         assert((a & 0xFFFF0000) == 0);
35         assert((b & 0xFFFF0000) == 0);
36         return MAKELONG(cast(ushort)a, cast(ushort)b);
37     }
38 
39     ushort LOWORD(ulong l) {
40         return cast(ushort) l;
41     }
42 
43     ushort HIWORD(ulong l) {
44         return cast(ushort) (l >>> 16);
45     }
46 
47     ubyte LOBYTE(ushort w) {
48         return cast(ubyte) w;
49     }
50 
51     ubyte HIBYTE(ushort w) {
52         return cast(ubyte) (w >>> 8);
53     }
54 }
55 
56 enum NULL = null;
57 static assert (is(typeof({
58     void test(int* p) {}
59     test(NULL);
60 })));
61 
62 alias ubyte        BYTE;
63 alias ubyte*       PBYTE, LPBYTE;
64 alias ushort       USHORT, WORD, ATOM;
65 alias ushort*      PUSHORT, PWORD, LPWORD;
66 alias uint         ULONG, DWORD, UINT, COLORREF;
67 alias uint*        PULONG, PDWORD, LPDWORD, PUINT, LPUINT, LPCOLORREF;
68 alias int          WINBOOL, BOOL, INT, LONG, HFILE, HRESULT;
69 alias int*         PWINBOOL, LPWINBOOL, PBOOL, LPBOOL, PINT, LPINT, LPLONG;
70 alias float        FLOAT;
71 alias float*       PFLOAT;
72 alias const(void)* PCVOID, LPCVOID;
73 
74 alias UINT_PTR WPARAM;
75 alias LONG_PTR LPARAM, LRESULT;
76 
77 mixin DECLARE_HANDLE!("HHOOK");
78 mixin DECLARE_HANDLE!("HGLOBAL");
79 mixin DECLARE_HANDLE!("HLOCAL");
80 mixin DECLARE_HANDLE!("GLOBALHANDLE");
81 mixin DECLARE_HANDLE!("LOCALHANDLE");
82 mixin DECLARE_HANDLE!("HGDIOBJ");
83 mixin DECLARE_HANDLE!("HACCEL");
84 mixin DECLARE_HANDLE!("HBITMAP", HGDIOBJ);
85 mixin DECLARE_HANDLE!("HBRUSH", HGDIOBJ);
86 mixin DECLARE_HANDLE!("HCOLORSPACE");
87 mixin DECLARE_HANDLE!("HDC");
88 mixin DECLARE_HANDLE!("HGLRC");
89 mixin DECLARE_HANDLE!("HDESK");
90 mixin DECLARE_HANDLE!("HENHMETAFILE");
91 mixin DECLARE_HANDLE!("HFONT", HGDIOBJ);
92 mixin DECLARE_HANDLE!("HICON");
93 mixin DECLARE_HANDLE!("HINSTANCE");
94 mixin DECLARE_HANDLE!("HKEY");
95 mixin DECLARE_HANDLE!("HMENU");
96 mixin DECLARE_HANDLE!("HMETAFILE");
97 mixin DECLARE_HANDLE!("HMODULE");
98 mixin DECLARE_HANDLE!("HMONITOR");
99 mixin DECLARE_HANDLE!("HPALETTE");
100 mixin DECLARE_HANDLE!("HPEN", HGDIOBJ);
101 mixin DECLARE_HANDLE!("HRGN", HGDIOBJ);
102 mixin DECLARE_HANDLE!("HRSRC");
103 mixin DECLARE_HANDLE!("HSTR");
104 mixin DECLARE_HANDLE!("HTASK");
105 mixin DECLARE_HANDLE!("HWND");
106 mixin DECLARE_HANDLE!("HWINSTA");
107 mixin DECLARE_HANDLE!("HKL");
108 mixin DECLARE_HANDLE!("HCURSOR");
109 alias HKEY* PHKEY;
110 
111 static if (_WIN32_WINNT >= 0x500) {
112     mixin DECLARE_HANDLE!("HTERMINAL");
113     mixin DECLARE_HANDLE!("HWINEVENTHOOK");
114 }
115 
116 alias extern (Windows) INT_PTR function() nothrow FARPROC, NEARPROC, PROC;
117 
118 struct RECT {
119     LONG left;
120     LONG top;
121     LONG right;
122     LONG bottom;
123 }
124 alias RECT RECTL;
125 alias RECT*        PRECT, NPRECT, LPRECT, PRECTL, LPRECTL;
126 alias const(RECT)* LPCRECT, LPCRECTL;
127 
128 struct POINT {
129     LONG x;
130     LONG y;
131 }
132 alias POINT POINTL;
133 alias POINT* PPOINT, NPPOINT, LPPOINT, PPOINTL, LPPOINTL;
134 
135 struct SIZE {
136     LONG cx;
137     LONG cy;
138 }
139 alias SIZE SIZEL;
140 alias SIZE* PSIZE, LPSIZE, PSIZEL, LPSIZEL;
141 
142 struct POINTS {
143     SHORT x;
144     SHORT y;
145 }
146 alias POINTS* PPOINTS, LPPOINTS;
147 
148 enum : BOOL {
149     FALSE = 0,
150     TRUE  = 1
151 }