user32.odin 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. // +build windows
  2. package sys_windows
  3. import "base:intrinsics"
  4. foreign import user32 "system:User32.lib"
  5. @(default_calling_convention="system")
  6. foreign user32 {
  7. GetClassInfoW :: proc(hInstance: HINSTANCE, lpClassNAme: LPCWSTR, lpWndClass: ^WNDCLASSW) -> BOOL ---
  8. GetClassInfoExW :: proc(hInsatnce: HINSTANCE, lpszClass: LPCWSTR, lpwcx: ^WNDCLASSEXW) -> BOOL ---
  9. GetClassLongW :: proc(hWnd: HWND, nIndex: c_int) -> DWORD ---
  10. SetClassLongW :: proc(hWnd: HWND, nIndex: c_int, dwNewLong: LONG) -> DWORD ---
  11. GetWindowLongW :: proc(hWnd: HWND, nIndex: c_int) -> LONG ---
  12. SetWindowLongW :: proc(hWnd: HWND, nIndex: c_int, dwNewLong: LONG) -> LONG ---
  13. GetClassNameW :: proc(hWnd: HWND, lpClassName: LPWSTR, nMaxCount: c_int) -> c_int ---
  14. RegisterClassW :: proc(lpWndClass: ^WNDCLASSW) -> ATOM ---
  15. RegisterClassExW :: proc(^WNDCLASSEXW) -> ATOM ---
  16. UnregisterClassW :: proc(lpClassName: LPCWSTR, hInstance: HINSTANCE) -> BOOL ---
  17. CreateWindowExW :: proc(
  18. dwExStyle: DWORD,
  19. lpClassName: LPCWSTR,
  20. lpWindowName: LPCWSTR,
  21. dwStyle: DWORD,
  22. X: c_int,
  23. Y: c_int,
  24. nWidth: c_int,
  25. nHeight: c_int,
  26. hWndParent: HWND,
  27. hMenu: HMENU,
  28. hInstance: HINSTANCE,
  29. lpParam: LPVOID,
  30. ) -> HWND ---
  31. DestroyWindow :: proc(hWnd: HWND) -> BOOL ---
  32. ShowWindow :: proc(hWnd: HWND, nCmdShow: c_int) -> BOOL ---
  33. IsWindow :: proc(hWnd: HWND) -> BOOL ---
  34. BringWindowToTop :: proc(hWnd: HWND) -> BOOL ---
  35. GetTopWindow :: proc(hWnd: HWND) -> HWND ---
  36. SetForegroundWindow :: proc(hWnd: HWND) -> BOOL ---
  37. GetForegroundWindow :: proc() -> HWND ---
  38. UpdateWindow :: proc(hWnd: HWND) -> BOOL ---
  39. SetActiveWindow :: proc(hWnd: HWND) -> HWND ---
  40. GetActiveWindow :: proc() -> HWND ---
  41. RedrawWindow :: proc(hwnd: HWND, lprcUpdate: LPRECT, hrgnUpdate: HRGN, flags: RedrawWindowFlags) -> BOOL ---
  42. GetMessageW :: proc(lpMsg: ^MSG, hWnd: HWND, wMsgFilterMin: UINT, wMsgFilterMax: UINT) -> BOOL ---
  43. TranslateMessage :: proc(lpMsg: ^MSG) -> BOOL ---
  44. DispatchMessageW :: proc(lpMsg: ^MSG) -> LRESULT ---
  45. WaitMessage :: proc() -> BOOL ---
  46. MsgWaitForMultipleObjects :: proc(nCount: DWORD, pHandles: ^HANDLE, fWaitAll: bool, dwMilliseconds: DWORD, dwWakeMask: DWORD) -> DWORD ---
  47. PeekMessageA :: proc(lpMsg: ^MSG, hWnd: HWND, wMsgFilterMin: UINT, wMsgFilterMax: UINT, wRemoveMsg: UINT) -> BOOL ---
  48. PeekMessageW :: proc(lpMsg: ^MSG, hWnd: HWND, wMsgFilterMin: UINT, wMsgFilterMax: UINT, wRemoveMsg: UINT) -> BOOL ---
  49. PostMessageA :: proc(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> BOOL ---
  50. PostMessageW :: proc(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> BOOL ---
  51. SendMessageA :: proc(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> LRESULT ---
  52. SendMessageW :: proc(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> LRESULT ---
  53. PostThreadMessageA :: proc(idThread: DWORD, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> BOOL ---
  54. PostThreadMessageW :: proc(idThread: DWORD, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> BOOL ---
  55. PostQuitMessage :: proc(nExitCode: c_int) ---
  56. GetQueueStatus :: proc(flags: UINT) -> DWORD ---
  57. DefWindowProcA :: proc(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> LRESULT ---
  58. DefWindowProcW :: proc(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> LRESULT ---
  59. FindWindowA :: proc(lpClassName: LPCSTR, lpWindowName: LPCSTR) -> HWND ---
  60. FindWindowW :: proc(lpClassName: LPCWSTR, lpWindowName: LPCWSTR) -> HWND ---
  61. FindWindowExA :: proc(hWndParent: HWND, hWndChildAfter: HWND, lpszClass: LPCSTR, lpszWindow: LPCSTR) -> HWND ---
  62. FindWindowExW :: proc(hWndParent: HWND, hWndChildAfter: HWND, lpszClass: LPCWSTR, lpszWindow: LPCWSTR) -> HWND ---
  63. LoadIconA :: proc(hInstance: HINSTANCE, lpIconName: LPCSTR) -> HICON ---
  64. LoadIconW :: proc(hInstance: HINSTANCE, lpIconName: LPCWSTR) -> HICON ---
  65. LoadCursorA :: proc(hInstance: HINSTANCE, lpCursorName: LPCSTR) -> HCURSOR ---
  66. LoadCursorW :: proc(hInstance: HINSTANCE, lpCursorName: LPCWSTR) -> HCURSOR ---
  67. LoadImageW :: proc(hInst: HINSTANCE, name: LPCWSTR, type: UINT, cx: c_int, cy: c_int, fuLoad: UINT) -> HANDLE ---
  68. CreateIcon :: proc(hInstance: HINSTANCE, nWidth: c_int, nHeight: c_int, cPlanes: BYTE, cBitsPixel: BYTE, lpbANDbits: PBYTE, lpbXORbits: PBYTE) -> HICON ---
  69. CreateIconFromResource :: proc(presbits: PBYTE, dwResSize: DWORD, fIcon: BOOL, dwVer: DWORD) -> HICON ---
  70. DestroyIcon :: proc(hIcon: HICON) -> BOOL ---
  71. DrawIcon :: proc(hDC: HDC, X: c_int, Y: c_int, hIcon: HICON) -> BOOL ---
  72. CreateCursor :: proc(hInst: HINSTANCE, xHotSpot: c_int, yHotSpot: c_int, nWidth: c_int, nHeight: c_int, pvANDPlane: PVOID, pvXORPlane: PVOID) -> HCURSOR ---
  73. DestroyCursor :: proc(hCursor: HCURSOR) -> BOOL ---
  74. GetWindowRect :: proc(hWnd: HWND, lpRect: LPRECT) -> BOOL ---
  75. GetClientRect :: proc(hWnd: HWND, lpRect: LPRECT) -> BOOL ---
  76. ClientToScreen :: proc(hWnd: HWND, lpPoint: LPPOINT) -> BOOL ---
  77. ScreenToClient :: proc(hWnd: HWND, lpPoint: LPPOINT) -> BOOL ---
  78. SetWindowPos :: proc(
  79. hWnd: HWND,
  80. hWndInsertAfter: HWND,
  81. X: c_int,
  82. Y: c_int,
  83. cx: c_int,
  84. cy: c_int,
  85. uFlags: UINT,
  86. ) -> BOOL ---
  87. MoveWindow :: proc(hWnd: HWND, X, Y, hWidth, hHeight: c_int, bRepaint: BOOL) -> BOOL ---
  88. GetSystemMetrics :: proc(nIndex: c_int) -> c_int ---
  89. AdjustWindowRect :: proc(lpRect: LPRECT, dwStyle: DWORD, bMenu: BOOL) -> BOOL ---
  90. AdjustWindowRectEx :: proc(lpRect: LPRECT, dwStyle: DWORD, bMenu: BOOL, dwExStyle: DWORD) -> BOOL ---
  91. AdjustWindowRectExForDpi :: proc(lpRect: LPRECT, dwStyle: DWORD, bMenu: BOOL, dwExStyle: DWORD, dpi: UINT) -> BOOL ---
  92. SystemParametersInfoW :: proc(uiAction, uiParam: UINT, pvParam: PVOID, fWinIni: UINT) -> BOOL ---
  93. GetMonitorInfoW :: proc(hMonitor: HMONITOR, lpmi: LPMONITORINFO) -> BOOL ---
  94. GetWindowDC :: proc(hWnd: HWND) -> HDC ---
  95. GetDC :: proc(hWnd: HWND) -> HDC ---
  96. ReleaseDC :: proc(hWnd: HWND, hDC: HDC) -> c_int ---
  97. GetDlgCtrlID :: proc(hWnd: HWND) -> c_int ---
  98. GetDlgItem :: proc(hDlg: HWND, nIDDlgItem: c_int) -> HWND ---
  99. CreatePopupMenu :: proc() -> HMENU ---
  100. DestroyMenu :: proc(hMenu: HMENU) -> BOOL ---
  101. AppendMenuW :: proc(hMenu: HMENU, uFlags: UINT, uIDNewItem: UINT_PTR, lpNewItem: LPCWSTR) -> BOOL ---
  102. SetMenu :: proc(hWnd: HWND, hMenu: HMENU) -> BOOL ---
  103. TrackPopupMenu :: proc(hMenu: HMENU, uFlags: UINT, x: int, y: int, nReserved: int, hWnd: HWND, prcRect: ^RECT) -> i32 ---
  104. RegisterWindowMessageW :: proc(lpString: LPCWSTR) -> UINT ---
  105. GetUpdateRect :: proc(hWnd: HWND, lpRect: LPRECT, bErase: BOOL) -> BOOL ---
  106. ValidateRect :: proc(hWnd: HWND, lpRect: ^RECT) -> BOOL ---
  107. InvalidateRect :: proc(hWnd: HWND, lpRect: ^RECT, bErase: BOOL) -> BOOL ---
  108. BeginPaint :: proc(hWnd: HWND, lpPaint: ^PAINTSTRUCT) -> HDC ---
  109. EndPaint :: proc(hWnd: HWND, lpPaint: ^PAINTSTRUCT) -> BOOL ---
  110. GetCapture :: proc() -> HWND ---
  111. SetCapture :: proc(hWnd: HWND) -> HWND ---
  112. ReleaseCapture :: proc() -> BOOL ---
  113. TrackMouseEvent :: proc(lpEventTrack: LPTRACKMOUSEEVENT) -> BOOL ---
  114. GetKeyState :: proc(nVirtKey: c_int) -> SHORT ---
  115. GetAsyncKeyState :: proc(vKey: c_int) -> SHORT ---
  116. GetKeyboardState :: proc(lpKeyState: PBYTE) -> BOOL ---
  117. MapVirtualKeyW :: proc(uCode: UINT, uMapType: UINT) -> UINT ---
  118. ToUnicode :: proc(nVirtKey: UINT, wScanCode: UINT, lpKeyState: ^BYTE, pwszBuff: LPWSTR, cchBuff: c_int, wFlags: UINT) -> c_int ---
  119. SetWindowsHookExW :: proc(idHook: c_int, lpfn: HOOKPROC, hmod: HINSTANCE, dwThreadId: DWORD) -> HHOOK ---
  120. UnhookWindowsHookEx :: proc(hhk: HHOOK) -> BOOL ---
  121. CallNextHookEx :: proc(hhk: HHOOK, nCode: c_int, wParam: WPARAM, lParam: LPARAM) -> LRESULT ---
  122. SetTimer :: proc(hWnd: HWND, nIDEvent: UINT_PTR, uElapse: UINT, lpTimerFunc: TIMERPROC) -> UINT_PTR ---
  123. KillTimer :: proc(hWnd: HWND, uIDEvent: UINT_PTR) -> BOOL ---
  124. // MessageBoxA :: proc(hWnd: HWND, lpText: LPCSTR, lpCaption: LPCSTR, uType: UINT) -> c_int ---
  125. MessageBoxW :: proc(hWnd: HWND, lpText: LPCWSTR, lpCaption: LPCWSTR, uType: UINT) -> c_int ---
  126. // MessageBoxExA :: proc(hWnd: HWND, lpText: LPCSTR, lpCaption: LPCSTR, uType: UINT, wLanguageId: WORD) -> c_int ---
  127. MessageBoxExW :: proc(hWnd: HWND, lpText: LPCWSTR, lpCaption: LPCWSTR, uType: UINT, wLanguageId: WORD) -> c_int ---
  128. ClipCursor :: proc(lpRect: LPRECT) -> BOOL ---
  129. GetCursorPos :: proc(lpPoint: LPPOINT) -> BOOL ---
  130. SetCursorPos :: proc(X: c_int, Y: c_int) -> BOOL ---
  131. SetCursor :: proc(hCursor: HCURSOR) -> HCURSOR ---
  132. when !intrinsics.is_package_imported("raylib") {
  133. ShowCursor :: proc(bShow: BOOL) -> INT ---
  134. }
  135. EnumDisplaySettingsW :: proc(lpszDeviceName: LPCWSTR, iModeNum: DWORD, lpDevMode: ^DEVMODEW) -> BOOL ---
  136. MonitorFromPoint :: proc(pt: POINT, dwFlags: Monitor_From_Flags) -> HMONITOR ---
  137. MonitorFromRect :: proc(lprc: LPRECT, dwFlags: Monitor_From_Flags) -> HMONITOR ---
  138. MonitorFromWindow :: proc(hwnd: HWND, dwFlags: Monitor_From_Flags) -> HMONITOR ---
  139. EnumDisplayMonitors :: proc(hdc: HDC, lprcClip: LPRECT, lpfnEnum: Monitor_Enum_Proc, dwData: LPARAM) -> BOOL ---
  140. EnumWindows :: proc(lpEnumFunc: Window_Enum_Proc, lParam: LPARAM) -> BOOL ---
  141. SetThreadDpiAwarenessContext :: proc(dpiContext: DPI_AWARENESS_CONTEXT) -> DPI_AWARENESS_CONTEXT ---
  142. GetThreadDpiAwarenessContext :: proc() -> DPI_AWARENESS_CONTEXT ---
  143. GetWindowDpiAwarenessContext :: proc(hwnd: HWND) -> DPI_AWARENESS_CONTEXT ---
  144. GetDpiFromDpiAwarenessContext :: proc(value: DPI_AWARENESS_CONTEXT) -> UINT ---
  145. GetDpiForWindow :: proc(hwnd: HWND) -> UINT ---
  146. SetProcessDpiAwarenessContext :: proc(value: DPI_AWARENESS_CONTEXT) -> BOOL ---
  147. BroadcastSystemMessageW :: proc(
  148. flags: DWORD,
  149. lpInfo: LPDWORD,
  150. Msg: UINT,
  151. wParam: WPARAM,
  152. lParam: LPARAM,
  153. ) -> c_long ---
  154. BroadcastSystemMessageExW :: proc(
  155. flags: DWORD,
  156. lpInfo: LPDWORD,
  157. Msg: UINT,
  158. wParam: WPARAM,
  159. lParam: LPARAM,
  160. pbsmInfo: PBSMINFO,
  161. ) -> c_long ---
  162. SendMessageTimeoutW :: proc(
  163. hWnd: HWND,
  164. Msg: UINT,
  165. wParam: WPARAM,
  166. lParam: LPARAM,
  167. fuFlags: UINT,
  168. uTimeout: UINT,
  169. lpdwResult: PDWORD_PTR,
  170. ) -> LRESULT ---
  171. GetSysColor :: proc(nIndex: c_int) -> DWORD ---
  172. GetSysColorBrush :: proc(nIndex: c_int) -> HBRUSH ---
  173. SetSysColors :: proc(cElements: c_int, lpaElements: ^INT, lpaRgbValues: ^COLORREF) -> BOOL ---
  174. MessageBeep :: proc(uType: UINT) -> BOOL ---
  175. IsDialogMessageW :: proc(hDlg: HWND, lpMsg: LPMSG) -> BOOL ---
  176. GetWindowTextLengthW :: proc(hWnd: HWND) -> c_int ---
  177. GetWindowTextW :: proc(hWnd: HWND, lpString: LPWSTR, nMaxCount: c_int) -> c_int ---
  178. SetWindowTextW :: proc(hWnd: HWND, lpString: LPCWSTR) -> BOOL ---
  179. CallWindowProcW :: proc(lpPrevWndFunc: WNDPROC, hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> LRESULT ---
  180. EnableWindow :: proc(hWnd: HWND, bEnable: BOOL) -> BOOL ---
  181. DefRawInputProc :: proc(paRawInput: ^PRAWINPUT, nInput: INT, cbSizeHeader: UINT) -> LRESULT ---
  182. GetRawInputBuffer :: proc(pRawInput: PRAWINPUT, pcbSize: PUINT, cbSizeHeader: UINT) -> UINT ---
  183. GetRawInputData :: proc(hRawInput: HRAWINPUT, uiCommand: UINT, pData: LPVOID, pcbSize: PUINT, cbSizeHeader: UINT) -> UINT ---
  184. GetRawInputDeviceInfoW :: proc(hDevice: HANDLE, uiCommand: UINT, pData: LPVOID, pcbSize: PUINT) -> UINT ---
  185. GetRawInputDeviceList :: proc(pRawInputDeviceList: PRAWINPUTDEVICELIST, puiNumDevices: PUINT, cbSize: UINT) -> UINT ---
  186. GetRegisteredRawInputDevices :: proc(pRawInputDevices: PRAWINPUTDEVICE, puiNumDevices: PUINT, cbSize: UINT) -> UINT ---
  187. RegisterRawInputDevices :: proc(pRawInputDevices: PCRAWINPUTDEVICE, uiNumDevices: UINT, cbSize: UINT) -> BOOL ---
  188. SendInput :: proc(cInputs: UINT, pInputs: [^]INPUT, cbSize: c_int) -> UINT ---
  189. SetLayeredWindowAttributes :: proc(hWnd: HWND, crKey: COLORREF, bAlpha: BYTE, dwFlags: DWORD) -> BOOL ---
  190. FillRect :: proc(hDC: HDC, lprc: ^RECT, hbr: HBRUSH) -> int ---
  191. EqualRect :: proc(lprc1: ^RECT, lprc2: ^RECT) -> BOOL ---
  192. GetWindowInfo :: proc(hwnd: HWND, pwi: PWINDOWINFO) -> BOOL ---
  193. GetWindowPlacement :: proc(hWnd: HWND, lpwndpl: ^WINDOWPLACEMENT) -> BOOL ---
  194. SetWindowPlacement :: proc(hwnd: HWND, lpwndpl: ^WINDOWPLACEMENT) -> BOOL ---
  195. SetWindowRgn :: proc(hWnd: HWND, hRgn: HRGN, bRedraw: BOOL) -> int ---
  196. CreateRectRgnIndirect :: proc(lprect: ^RECT) -> HRGN ---
  197. GetSystemMetricsForDpi :: proc(nIndex: int, dpi: UINT) -> int ---
  198. GetSystemMenu :: proc(hWnd: HWND, bRevert: BOOL) -> HMENU ---
  199. EnableMenuItem :: proc(hMenu: HMENU, uIDEnableItem: UINT, uEnable: UINT) -> BOOL ---
  200. DrawTextW :: proc(hdc: HDC, lpchText: LPCWSTR, cchText: INT, lprc: LPRECT, format: DrawTextFormat) -> INT ---
  201. DrawTextExW :: proc(hdc: HDC, lpchText: LPCWSTR, cchText: INT, lprc: LPRECT, format: DrawTextFormat, lpdtp: PDRAWTEXTPARAMS) -> INT ---
  202. }
  203. CreateWindowW :: #force_inline proc "system" (
  204. lpClassName: LPCTSTR,
  205. lpWindowName: LPCTSTR,
  206. dwStyle: DWORD,
  207. X: c_int,
  208. Y: c_int,
  209. nWidth: c_int,
  210. nHeight: c_int,
  211. hWndParent: HWND,
  212. hMenu: HMENU,
  213. hInstance: HINSTANCE,
  214. lpParam: LPVOID,
  215. ) -> HWND {
  216. return CreateWindowExW(
  217. 0,
  218. lpClassName,
  219. lpWindowName,
  220. dwStyle,
  221. X,
  222. Y,
  223. nWidth,
  224. nHeight,
  225. hWndParent,
  226. hMenu,
  227. hInstance,
  228. lpParam,
  229. )
  230. }
  231. when ODIN_ARCH == .amd64 {
  232. @(default_calling_convention="system")
  233. foreign user32 {
  234. GetClassLongPtrW :: proc(hWnd: HWND, nIndex: c_int) -> ULONG_PTR ---
  235. SetClassLongPtrW :: proc(hWnd: HWND, nIndex: c_int, dwNewLong: LONG_PTR) -> ULONG_PTR ---
  236. GetWindowLongPtrW :: proc(hWnd: HWND, nIndex: c_int) -> LONG_PTR ---
  237. SetWindowLongPtrW :: proc(hWnd: HWND, nIndex: c_int, dwNewLong: LONG_PTR) -> LONG_PTR ---
  238. }
  239. } else when ODIN_ARCH == .i386 {
  240. GetClassLongPtrW :: GetClassLongW
  241. SetClassLongPtrW :: SetClassLongW
  242. GetWindowLongPtrW :: GetWindowLongW
  243. SetWindowLongPtrW :: SetWindowLongW
  244. }
  245. GET_SC_WPARAM :: #force_inline proc "contextless" (wParam: WPARAM) -> c_int {
  246. return c_int(wParam) & 0xFFF0
  247. }
  248. GET_WHEEL_DELTA_WPARAM :: #force_inline proc "contextless" (wParam: WPARAM) -> c_short {
  249. return cast(c_short)HIWORD(cast(DWORD)wParam)
  250. }
  251. GET_KEYSTATE_WPARAM :: #force_inline proc "contextless" (wParam: WPARAM) -> WORD {
  252. return LOWORD(cast(DWORD)wParam)
  253. }
  254. GET_NCHITTEST_WPARAM :: #force_inline proc "contextless" (wParam: WPARAM) -> c_short {
  255. return cast(c_short)LOWORD(cast(DWORD)wParam)
  256. }
  257. GET_XBUTTON_WPARAM :: #force_inline proc "contextless" (wParam: WPARAM) -> WORD {
  258. return HIWORD(cast(DWORD)wParam)
  259. }
  260. MAKEINTRESOURCEW :: #force_inline proc "contextless" (#any_int i: int) -> LPWSTR {
  261. return cast(LPWSTR)uintptr(WORD(i))
  262. }
  263. Monitor_From_Flags :: enum DWORD {
  264. MONITOR_DEFAULTTONULL = 0x00000000, // Returns NULL
  265. MONITOR_DEFAULTTOPRIMARY = 0x00000001, // Returns a handle to the primary display monitor
  266. MONITOR_DEFAULTTONEAREST = 0x00000002, // Returns a handle to the display monitor that is nearest to the window
  267. }
  268. Monitor_Enum_Proc :: #type proc "system" (HMONITOR, HDC, LPRECT, LPARAM) -> BOOL
  269. Window_Enum_Proc :: #type proc "system" (HWND, LPARAM) -> BOOL
  270. USER_DEFAULT_SCREEN_DPI :: 96
  271. DPI_AWARENESS_CONTEXT :: distinct HANDLE
  272. DPI_AWARENESS_CONTEXT_UNAWARE :: DPI_AWARENESS_CONTEXT(~uintptr(0)) // -1
  273. DPI_AWARENESS_CONTEXT_SYSTEM_AWARE :: DPI_AWARENESS_CONTEXT(~uintptr(1)) // -2
  274. DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE :: DPI_AWARENESS_CONTEXT(~uintptr(2)) // -3
  275. DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 :: DPI_AWARENESS_CONTEXT(~uintptr(3)) // -4
  276. DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED :: DPI_AWARENESS_CONTEXT(~uintptr(4)) // -5
  277. RAWINPUTHEADER :: struct {
  278. dwType: DWORD,
  279. dwSize: DWORD,
  280. hDevice: HANDLE,
  281. wParam: WPARAM,
  282. }
  283. RAWHID :: struct {
  284. dwSizeHid: DWORD,
  285. dwCount: DWORD,
  286. bRawData: [1]BYTE,
  287. }
  288. RAWMOUSE :: struct {
  289. usFlags: USHORT,
  290. DUMMYUNIONNAME: struct #raw_union {
  291. ulButtons: ULONG,
  292. DUMMYSTRUCTNAME: struct {
  293. usButtonFlags: USHORT,
  294. usButtonData: USHORT,
  295. },
  296. },
  297. ulRawButtons: ULONG,
  298. lLastX: LONG,
  299. lLastY: LONG,
  300. ulExtraInformation: ULONG,
  301. }
  302. RAWKEYBOARD :: struct {
  303. MakeCode: USHORT,
  304. Flags: USHORT,
  305. Rserved: USHORT,
  306. VKey: USHORT,
  307. Message: UINT,
  308. ExtraInformation: ULONG,
  309. }
  310. RAWINPUT :: struct {
  311. header: RAWINPUTHEADER,
  312. data: struct #raw_union {
  313. mouse: RAWMOUSE,
  314. keyboard: RAWKEYBOARD,
  315. hid: RAWHID,
  316. },
  317. }
  318. PRAWINPUT :: ^RAWINPUT
  319. HRAWINPUT :: distinct LPARAM
  320. RAWINPUTDEVICE :: struct {
  321. usUsagePage: USHORT,
  322. usUsage: USHORT,
  323. dwFlags: DWORD,
  324. hwndTarget: HWND,
  325. }
  326. PRAWINPUTDEVICE :: ^RAWINPUTDEVICE
  327. PCRAWINPUTDEVICE :: PRAWINPUTDEVICE
  328. RAWINPUTDEVICELIST :: struct {
  329. hDevice: HANDLE,
  330. dwType: DWORD,
  331. }
  332. PRAWINPUTDEVICELIST :: ^RAWINPUTDEVICELIST
  333. RID_DEVICE_INFO_HID :: struct {
  334. dwVendorId: DWORD,
  335. dwProductId: DWORD,
  336. dwVersionNumber: DWORD,
  337. usUsagePage: USHORT,
  338. usUsage: USHORT,
  339. }
  340. RID_DEVICE_INFO_KEYBOARD :: struct {
  341. dwType: DWORD,
  342. dwSubType: DWORD,
  343. dwKeyboardMode: DWORD,
  344. dwNumberOfFunctionKeys: DWORD,
  345. dwNumberOfIndicators: DWORD,
  346. dwNumberOfKeysTotal: DWORD,
  347. }
  348. RID_DEVICE_INFO_MOUSE :: struct {
  349. dwId: DWORD,
  350. dwNumberOfButtons: DWORD,
  351. dwSampleRate: DWORD,
  352. fHasHorizontalWheel: BOOL,
  353. }
  354. RID_DEVICE_INFO :: struct {
  355. cbSize: DWORD,
  356. dwType: DWORD,
  357. DUMMYUNIONNAME: struct #raw_union {
  358. mouse: RID_DEVICE_INFO_MOUSE,
  359. keyboard: RID_DEVICE_INFO_KEYBOARD,
  360. hid: RID_DEVICE_INFO_HID,
  361. },
  362. }
  363. RIDEV_REMOVE :: 0x00000001
  364. RIDEV_EXCLUDE :: 0x00000010
  365. RIDEV_PAGEONLY :: 0x00000020
  366. RIDEV_NOLEGACY :: 0x00000030
  367. RIDEV_INPUTSINK :: 0x00000100
  368. RIDEV_CAPTUREMOUSE :: 0x00000200
  369. RIDEV_NOHOTKEYS :: 0x00000200
  370. RIDEV_APPKEYS :: 0x00000400
  371. RIDEV_EXINPUTSINK :: 0x00001000
  372. RIDEV_DEVNOTIFY :: 0x00002000
  373. RID_HEADER :: 0x10000005
  374. RID_INPUT :: 0x10000003
  375. RIM_TYPEMOUSE :: 0
  376. RIM_TYPEKEYBOARD :: 1
  377. RIM_TYPEHID :: 2
  378. MOUSE_MOVE_RELATIVE :: 0x00
  379. MOUSE_MOVE_ABSOLUTE :: 0x01
  380. MOUSE_VIRTUAL_DESKTOP :: 0x02
  381. MOUSE_ATTRIUBTTES_CHANGED :: 0x04
  382. MOUSE_MOVE_NOCOALESCE :: 0x08
  383. RI_MOUSE_BUTTON_1_DOWN :: 0x0001
  384. RI_MOUSE_LEFT_BUTTON_DOWNS :: RI_MOUSE_BUTTON_1_DOWN
  385. RI_MOUSE_BUTTON_1_UP :: 0x0002
  386. RI_MOUSE_LEFT_BUTTON_UP :: RI_MOUSE_BUTTON_1_UP
  387. RI_MOUSE_BUTTON_2_DOWN :: 0x0004
  388. RI_MOUSE_RIGHT_BUTTON_DOWN :: RI_MOUSE_BUTTON_2_DOWN
  389. RI_MOUSE_BUTTON_2_UP :: 0x0008
  390. RI_MOUSE_RIGHT_BUTTON_UP :: RI_MOUSE_BUTTON_2_UP
  391. RI_MOUSE_BUTTON_3_DOWN :: 0x0010
  392. RI_MOUSE_MIDDLE_BUTTON_DOWN :: RI_MOUSE_BUTTON_3_DOWN
  393. RI_MOUSE_BUTTON_3_UP :: 0x0020
  394. RI_MOUSE_MIDDLE_BUTTON_UP :: RI_MOUSE_BUTTON_3_UP
  395. RI_MOUSE_BUTTON_4_DOWN :: 0x0040
  396. RI_MOUSE_BUTTON_4_UP :: 0x0080
  397. RI_MOUSE_BUTTON_5_DOWN :: 0x0100
  398. RI_MOUSE_BUTTON_5_UP :: 0x0200
  399. RI_MOUSE_WHEEL :: 0x0400
  400. RI_MOUSE_HWHEEL :: 0x0800
  401. HID_USAGE_PAGE_GENERIC :: 0x01
  402. HID_USAGE_PAGE_GAME :: 0x05
  403. HID_USAGE_PAGE_LED :: 0x08
  404. HID_USAGE_PAGE_BUTTON :: 0x09
  405. HID_USAGE_GENERIC_POINTER :: 0x01
  406. HID_USAGE_GENERIC_MOUSE :: 0x02
  407. HID_USAGE_GENERIC_JOYSTICK :: 0x04
  408. HID_USAGE_GENERIC_GAMEPAD :: 0x05
  409. HID_USAGE_GENERIC_KEYBOARD :: 0x06
  410. HID_USAGE_GENERIC_KEYPAD :: 0x07
  411. HID_USAGE_GENERIC_MULTI_AXIS_CONTROLLER :: 0x08
  412. WINDOWPLACEMENT :: struct {
  413. length: UINT,
  414. flags: UINT,
  415. showCmd: UINT,
  416. ptMinPosition: POINT,
  417. ptMaxPosition: POINT,
  418. rcNormalPosition: RECT,
  419. }
  420. WINDOWINFO :: struct {
  421. cbSize: DWORD,
  422. rcWindow: RECT,
  423. rcClient: RECT,
  424. dwStyle: DWORD,
  425. dwExStyle: DWORD,
  426. dwWindowStatus: DWORD,
  427. cxWindowBorders: UINT,
  428. cyWindowBorders: UINT,
  429. atomWindowType: ATOM,
  430. wCreatorVersion: WORD,
  431. }
  432. PWINDOWINFO :: ^WINDOWINFO
  433. DRAWTEXTPARAMS :: struct {
  434. cbSize : UINT ,
  435. iTabLength: int ,
  436. iLeftMargin: int ,
  437. iRightMargin: int ,
  438. uiLengthDrawn: UINT ,
  439. }
  440. PDRAWTEXTPARAMS :: ^DRAWTEXTPARAMS
  441. DrawTextFormat :: enum UINT {
  442. DT_TOP = 0x00000000,
  443. DT_LEFT = 0x00000000,
  444. DT_CENTER = 0x00000001,
  445. DT_RIGHT = 0x00000002,
  446. DT_VCENTER = 0x00000004,
  447. DT_BOTTOM = 0x00000008,
  448. DT_WORDBREAK = 0x00000010,
  449. DT_SINGLELINE = 0x00000020,
  450. DT_EXPANDTABS = 0x00000040,
  451. DT_TABSTOP = 0x00000080,
  452. DT_NOCLIP = 0x00000100,
  453. DT_EXTERNALLEADING = 0x00000200,
  454. DT_CALCRECT = 0x00000400,
  455. DT_NOPREFIX = 0x00000800,
  456. DT_INTERNAL = 0x00001000,
  457. DT_EDITCONTROL = 0x00002000,
  458. DT_PATH_ELLIPSIS = 0x00004000,
  459. DT_END_ELLIPSIS = 0x00008000,
  460. DT_MODIFYSTRING = 0x00010000,
  461. DT_RTLREADING = 0x00020000,
  462. DT_WORD_ELLIPSIS = 0x00040000,
  463. DT_NOFULLWIDTHCHARBREAK = 0x00080000,
  464. DT_HIDEPREFIX = 0x00100000,
  465. DT_PREFIXONLY = 0x00200000,
  466. }
  467. RedrawWindowFlags :: enum UINT {
  468. RDW_INVALIDATE = 0x0001,
  469. RDW_INTERNALPAINT = 0x0002,
  470. RDW_ERASE = 0x0004,
  471. RDW_VALIDATE = 0x0008,
  472. RDW_NOINTERNALPAINT = 0x0010,
  473. RDW_NOERASE = 0x0020,
  474. RDW_NOCHILDREN = 0x0040,
  475. RDW_ALLCHILDREN = 0x0080,
  476. RDW_UPDATENOW = 0x0100,
  477. RDW_ERASENOW = 0x0200,
  478. RDW_FRAME = 0x0400,
  479. RDW_NOFRAME = 0x0800,
  480. }