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