user32.odin 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  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. TrackPopupMenu :: proc(hMenu: HMENU, uFlags: UINT, x: int, y: int, nReserved: int, hWnd: HWND, prcRect: ^RECT) -> i32 ---
  103. RegisterWindowMessageW :: proc(lpString: LPCWSTR) -> UINT ---
  104. GetUpdateRect :: proc(hWnd: HWND, lpRect: LPRECT, bErase: BOOL) -> BOOL ---
  105. ValidateRect :: proc(hWnd: HWND, lpRect: ^RECT) -> BOOL ---
  106. InvalidateRect :: proc(hWnd: HWND, lpRect: ^RECT, bErase: BOOL) -> BOOL ---
  107. BeginPaint :: proc(hWnd: HWND, lpPaint: ^PAINTSTRUCT) -> HDC ---
  108. EndPaint :: proc(hWnd: HWND, lpPaint: ^PAINTSTRUCT) -> BOOL ---
  109. GetCapture :: proc() -> HWND ---
  110. SetCapture :: proc(hWnd: HWND) -> HWND ---
  111. ReleaseCapture :: proc() -> BOOL ---
  112. TrackMouseEvent :: proc(lpEventTrack: LPTRACKMOUSEEVENT) -> BOOL ---
  113. GetKeyState :: proc(nVirtKey: c_int) -> SHORT ---
  114. GetAsyncKeyState :: proc(vKey: c_int) -> SHORT ---
  115. GetKeyboardState :: proc(lpKeyState: PBYTE) -> BOOL ---
  116. MapVirtualKeyW :: proc(uCode: UINT, uMapType: UINT) -> UINT ---
  117. ToUnicode :: proc(nVirtKey: UINT, wScanCode: UINT, lpKeyState: ^BYTE, pwszBuff: LPWSTR, cchBuff: c_int, wFlags: UINT) -> c_int ---
  118. SetWindowsHookExW :: proc(idHook: c_int, lpfn: HOOKPROC, hmod: HINSTANCE, dwThreadId: DWORD) -> HHOOK ---
  119. UnhookWindowsHookEx :: proc(hhk: HHOOK) -> BOOL ---
  120. CallNextHookEx :: proc(hhk: HHOOK, nCode: c_int, wParam: WPARAM, lParam: LPARAM) -> LRESULT ---
  121. SetTimer :: proc(hWnd: HWND, nIDEvent: UINT_PTR, uElapse: UINT, lpTimerFunc: TIMERPROC) -> UINT_PTR ---
  122. KillTimer :: proc(hWnd: HWND, uIDEvent: UINT_PTR) -> BOOL ---
  123. // MessageBoxA :: proc(hWnd: HWND, lpText: LPCSTR, lpCaption: LPCSTR, uType: UINT) -> c_int ---
  124. MessageBoxW :: proc(hWnd: HWND, lpText: LPCWSTR, lpCaption: LPCWSTR, uType: UINT) -> c_int ---
  125. // MessageBoxExA :: proc(hWnd: HWND, lpText: LPCSTR, lpCaption: LPCSTR, uType: UINT, wLanguageId: WORD) -> c_int ---
  126. MessageBoxExW :: proc(hWnd: HWND, lpText: LPCWSTR, lpCaption: LPCWSTR, uType: UINT, wLanguageId: WORD) -> c_int ---
  127. ClipCursor :: proc(lpRect: LPRECT) -> BOOL ---
  128. GetCursorPos :: proc(lpPoint: LPPOINT) -> BOOL ---
  129. SetCursorPos :: proc(X: c_int, Y: c_int) -> BOOL ---
  130. SetCursor :: proc(hCursor: HCURSOR) -> HCURSOR ---
  131. when !intrinsics.is_package_imported("raylib") {
  132. ShowCursor :: proc(bShow: BOOL) -> INT ---
  133. }
  134. EnumDisplaySettingsW :: proc(lpszDeviceName: LPCWSTR, iModeNum: DWORD, lpDevMode: ^DEVMODEW) -> BOOL ---
  135. MonitorFromPoint :: proc(pt: POINT, dwFlags: Monitor_From_Flags) -> HMONITOR ---
  136. MonitorFromRect :: proc(lprc: LPRECT, dwFlags: Monitor_From_Flags) -> HMONITOR ---
  137. MonitorFromWindow :: proc(hwnd: HWND, dwFlags: Monitor_From_Flags) -> HMONITOR ---
  138. EnumDisplayMonitors :: proc(hdc: HDC, lprcClip: LPRECT, lpfnEnum: Monitor_Enum_Proc, dwData: LPARAM) -> BOOL ---
  139. EnumWindows :: proc(lpEnumFunc: Window_Enum_Proc, lParam: LPARAM) -> BOOL ---
  140. SetThreadDpiAwarenessContext :: proc(dpiContext: DPI_AWARENESS_CONTEXT) -> DPI_AWARENESS_CONTEXT ---
  141. GetThreadDpiAwarenessContext :: proc() -> DPI_AWARENESS_CONTEXT ---
  142. GetWindowDpiAwarenessContext :: proc(hwnd: HWND) -> DPI_AWARENESS_CONTEXT ---
  143. GetDpiFromDpiAwarenessContext :: proc(value: DPI_AWARENESS_CONTEXT) -> UINT ---
  144. GetDpiForWindow :: proc(hwnd: HWND) -> UINT ---
  145. SetProcessDpiAwarenessContext :: proc(value: DPI_AWARENESS_CONTEXT) -> BOOL ---
  146. BroadcastSystemMessageW :: proc(
  147. flags: DWORD,
  148. lpInfo: LPDWORD,
  149. Msg: UINT,
  150. wParam: WPARAM,
  151. lParam: LPARAM,
  152. ) -> c_long ---
  153. BroadcastSystemMessageExW :: proc(
  154. flags: DWORD,
  155. lpInfo: LPDWORD,
  156. Msg: UINT,
  157. wParam: WPARAM,
  158. lParam: LPARAM,
  159. pbsmInfo: PBSMINFO,
  160. ) -> c_long ---
  161. SendMessageTimeoutW :: proc(
  162. hWnd: HWND,
  163. Msg: UINT,
  164. wParam: WPARAM,
  165. lParam: LPARAM,
  166. fuFlags: UINT,
  167. uTimeout: UINT,
  168. lpdwResult: PDWORD_PTR,
  169. ) -> LRESULT ---
  170. GetSysColor :: proc(nIndex: c_int) -> DWORD ---
  171. GetSysColorBrush :: proc(nIndex: c_int) -> HBRUSH ---
  172. SetSysColors :: proc(cElements: c_int, lpaElements: ^INT, lpaRgbValues: ^COLORREF) -> BOOL ---
  173. MessageBeep :: proc(uType: UINT) -> BOOL ---
  174. IsDialogMessageW :: proc(hDlg: HWND, lpMsg: LPMSG) -> BOOL ---
  175. GetWindowTextLengthW :: proc(hWnd: HWND) -> c_int ---
  176. GetWindowTextW :: proc(hWnd: HWND, lpString: LPWSTR, nMaxCount: c_int) -> c_int ---
  177. SetWindowTextW :: proc(hWnd: HWND, lpString: LPCWSTR) -> BOOL ---
  178. CallWindowProcW :: proc(lpPrevWndFunc: WNDPROC, hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> LRESULT ---
  179. EnableWindow :: proc(hWnd: HWND, bEnable: BOOL) -> BOOL ---
  180. DefRawInputProc :: proc(paRawInput: ^PRAWINPUT, nInput: INT, cbSizeHeader: UINT) -> LRESULT ---
  181. GetRawInputBuffer :: proc(pRawInput: PRAWINPUT, pcbSize: PUINT, cbSizeHeader: UINT) -> UINT ---
  182. GetRawInputData :: proc(hRawInput: HRAWINPUT, uiCommand: UINT, pData: LPVOID, pcbSize: PUINT, cbSizeHeader: UINT) -> UINT ---
  183. GetRawInputDeviceInfoW :: proc(hDevice: HANDLE, uiCommand: UINT, pData: LPVOID, pcbSize: PUINT) -> UINT ---
  184. GetRawInputDeviceList :: proc(pRawInputDeviceList: PRAWINPUTDEVICELIST, puiNumDevices: PUINT, cbSize: UINT) -> UINT ---
  185. GetRegisteredRawInputDevices :: proc(pRawInputDevices: PRAWINPUTDEVICE, puiNumDevices: PUINT, cbSize: UINT) -> UINT ---
  186. RegisterRawInputDevices :: proc(pRawInputDevices: PCRAWINPUTDEVICE, uiNumDevices: UINT, cbSize: UINT) -> BOOL ---
  187. SendInput :: proc(cInputs: UINT, pInputs: [^]INPUT, cbSize: c_int) -> UINT ---
  188. SetLayeredWindowAttributes :: proc(hWnd: HWND, crKey: COLORREF, bAlpha: BYTE, dwFlags: DWORD) -> BOOL ---
  189. FillRect :: proc(hDC: HDC, lprc: ^RECT, hbr: HBRUSH) -> int ---
  190. EqualRect :: proc(lprc1: ^RECT, lprc2: ^RECT) -> BOOL ---
  191. GetWindowInfo :: proc(hwnd: HWND, pwi: PWINDOWINFO) -> BOOL ---
  192. GetWindowPlacement :: proc(hWnd: HWND, lpwndpl: ^WINDOWPLACEMENT) -> BOOL ---
  193. SetWindowPlacement :: proc(hwnd: HWND, lpwndpl: ^WINDOWPLACEMENT) -> BOOL ---
  194. SetWindowRgn :: proc(hWnd: HWND, hRgn: HRGN, bRedraw: BOOL) -> int ---
  195. CreateRectRgnIndirect :: proc(lprect: ^RECT) -> HRGN ---
  196. GetSystemMetricsForDpi :: proc(nIndex: int, dpi: UINT) -> int ---
  197. GetSystemMenu :: proc(hWnd: HWND, bRevert: BOOL) -> HMENU ---
  198. EnableMenuItem :: proc(hMenu: HMENU, uIDEnableItem: UINT, uEnable: UINT) -> BOOL ---
  199. DrawTextW :: proc(hdc: HDC, lpchText: LPCWSTR, cchText: INT, lprc: LPRECT, format: DrawTextFormat) -> INT ---
  200. DrawTextExW :: proc(hdc: HDC, lpchText: LPCWSTR, cchText: INT, lprc: LPRECT, format: DrawTextFormat, lpdtp: PDRAWTEXTPARAMS) -> INT ---
  201. }
  202. CreateWindowW :: #force_inline proc "system" (
  203. lpClassName: LPCTSTR,
  204. lpWindowName: LPCTSTR,
  205. dwStyle: DWORD,
  206. X: c_int,
  207. Y: c_int,
  208. nWidth: c_int,
  209. nHeight: c_int,
  210. hWndParent: HWND,
  211. hMenu: HMENU,
  212. hInstance: HINSTANCE,
  213. lpParam: LPVOID,
  214. ) -> HWND {
  215. return CreateWindowExW(
  216. 0,
  217. lpClassName,
  218. lpWindowName,
  219. dwStyle,
  220. X,
  221. Y,
  222. nWidth,
  223. nHeight,
  224. hWndParent,
  225. hMenu,
  226. hInstance,
  227. lpParam,
  228. )
  229. }
  230. when ODIN_ARCH == .amd64 {
  231. @(default_calling_convention="system")
  232. foreign user32 {
  233. GetClassLongPtrW :: proc(hWnd: HWND, nIndex: c_int) -> ULONG_PTR ---
  234. SetClassLongPtrW :: proc(hWnd: HWND, nIndex: c_int, dwNewLong: LONG_PTR) -> ULONG_PTR ---
  235. GetWindowLongPtrW :: proc(hWnd: HWND, nIndex: c_int) -> LONG_PTR ---
  236. SetWindowLongPtrW :: proc(hWnd: HWND, nIndex: c_int, dwNewLong: LONG_PTR) -> LONG_PTR ---
  237. }
  238. } else when ODIN_ARCH == .i386 {
  239. GetClassLongPtrW :: GetClassLongW
  240. SetClassLongPtrW :: SetClassLongW
  241. GetWindowLongPtrW :: GetWindowLongW
  242. SetWindowLongPtrW :: SetWindowLongW
  243. }
  244. GET_SC_WPARAM :: #force_inline proc "contextless" (wParam: WPARAM) -> c_int {
  245. return c_int(wParam) & 0xFFF0
  246. }
  247. GET_WHEEL_DELTA_WPARAM :: #force_inline proc "contextless" (wParam: WPARAM) -> c_short {
  248. return cast(c_short)HIWORD(cast(DWORD)wParam)
  249. }
  250. GET_KEYSTATE_WPARAM :: #force_inline proc "contextless" (wParam: WPARAM) -> WORD {
  251. return LOWORD(cast(DWORD)wParam)
  252. }
  253. GET_NCHITTEST_WPARAM :: #force_inline proc "contextless" (wParam: WPARAM) -> c_short {
  254. return cast(c_short)LOWORD(cast(DWORD)wParam)
  255. }
  256. GET_XBUTTON_WPARAM :: #force_inline proc "contextless" (wParam: WPARAM) -> WORD {
  257. return HIWORD(cast(DWORD)wParam)
  258. }
  259. MAKEINTRESOURCEW :: #force_inline proc "contextless" (#any_int i: int) -> LPWSTR {
  260. return cast(LPWSTR)uintptr(WORD(i))
  261. }
  262. Monitor_From_Flags :: enum DWORD {
  263. MONITOR_DEFAULTTONULL = 0x00000000, // Returns NULL
  264. MONITOR_DEFAULTTOPRIMARY = 0x00000001, // Returns a handle to the primary display monitor
  265. MONITOR_DEFAULTTONEAREST = 0x00000002, // Returns a handle to the display monitor that is nearest to the window
  266. }
  267. Monitor_Enum_Proc :: #type proc "system" (HMONITOR, HDC, LPRECT, LPARAM) -> BOOL
  268. Window_Enum_Proc :: #type proc "system" (HWND, LPARAM) -> BOOL
  269. USER_DEFAULT_SCREEN_DPI :: 96
  270. DPI_AWARENESS_CONTEXT :: distinct HANDLE
  271. DPI_AWARENESS_CONTEXT_UNAWARE :: DPI_AWARENESS_CONTEXT(~uintptr(0)) // -1
  272. DPI_AWARENESS_CONTEXT_SYSTEM_AWARE :: DPI_AWARENESS_CONTEXT(~uintptr(1)) // -2
  273. DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE :: DPI_AWARENESS_CONTEXT(~uintptr(2)) // -3
  274. DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 :: DPI_AWARENESS_CONTEXT(~uintptr(3)) // -4
  275. DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED :: DPI_AWARENESS_CONTEXT(~uintptr(4)) // -5
  276. RAWINPUTHEADER :: struct {
  277. dwType: DWORD,
  278. dwSize: DWORD,
  279. hDevice: HANDLE,
  280. wParam: WPARAM,
  281. }
  282. RAWHID :: struct {
  283. dwSizeHid: DWORD,
  284. dwCount: DWORD,
  285. bRawData: [1]BYTE,
  286. }
  287. RAWMOUSE :: struct {
  288. usFlags: USHORT,
  289. DUMMYUNIONNAME: struct #raw_union {
  290. ulButtons: ULONG,
  291. DUMMYSTRUCTNAME: struct {
  292. usButtonFlags: USHORT,
  293. usButtonData: USHORT,
  294. },
  295. },
  296. ulRawButtons: ULONG,
  297. lLastX: LONG,
  298. lLastY: LONG,
  299. ulExtraInformation: ULONG,
  300. }
  301. RAWKEYBOARD :: struct {
  302. MakeCode: USHORT,
  303. Flags: USHORT,
  304. Rserved: USHORT,
  305. VKey: USHORT,
  306. Message: UINT,
  307. ExtraInformation: ULONG,
  308. }
  309. RAWINPUT :: struct {
  310. header: RAWINPUTHEADER,
  311. data: struct #raw_union {
  312. mouse: RAWMOUSE,
  313. keyboard: RAWKEYBOARD,
  314. hid: RAWHID,
  315. },
  316. }
  317. PRAWINPUT :: ^RAWINPUT
  318. HRAWINPUT :: distinct LPARAM
  319. RAWINPUTDEVICE :: struct {
  320. usUsagePage: USHORT,
  321. usUsage: USHORT,
  322. dwFlags: DWORD,
  323. hwndTarget: HWND,
  324. }
  325. PRAWINPUTDEVICE :: ^RAWINPUTDEVICE
  326. PCRAWINPUTDEVICE :: PRAWINPUTDEVICE
  327. RAWINPUTDEVICELIST :: struct {
  328. hDevice: HANDLE,
  329. dwType: DWORD,
  330. }
  331. PRAWINPUTDEVICELIST :: ^RAWINPUTDEVICELIST
  332. RID_DEVICE_INFO_HID :: struct {
  333. dwVendorId: DWORD,
  334. dwProductId: DWORD,
  335. dwVersionNumber: DWORD,
  336. usUsagePage: USHORT,
  337. usUsage: USHORT,
  338. }
  339. RID_DEVICE_INFO_KEYBOARD :: struct {
  340. dwType: DWORD,
  341. dwSubType: DWORD,
  342. dwKeyboardMode: DWORD,
  343. dwNumberOfFunctionKeys: DWORD,
  344. dwNumberOfIndicators: DWORD,
  345. dwNumberOfKeysTotal: DWORD,
  346. }
  347. RID_DEVICE_INFO_MOUSE :: struct {
  348. dwId: DWORD,
  349. dwNumberOfButtons: DWORD,
  350. dwSampleRate: DWORD,
  351. fHasHorizontalWheel: BOOL,
  352. }
  353. RID_DEVICE_INFO :: struct {
  354. cbSize: DWORD,
  355. dwType: DWORD,
  356. DUMMYUNIONNAME: struct #raw_union {
  357. mouse: RID_DEVICE_INFO_MOUSE,
  358. keyboard: RID_DEVICE_INFO_KEYBOARD,
  359. hid: RID_DEVICE_INFO_HID,
  360. },
  361. }
  362. RIDEV_REMOVE :: 0x00000001
  363. RIDEV_EXCLUDE :: 0x00000010
  364. RIDEV_PAGEONLY :: 0x00000020
  365. RIDEV_NOLEGACY :: 0x00000030
  366. RIDEV_INPUTSINK :: 0x00000100
  367. RIDEV_CAPTUREMOUSE :: 0x00000200
  368. RIDEV_NOHOTKEYS :: 0x00000200
  369. RIDEV_APPKEYS :: 0x00000400
  370. RIDEV_EXINPUTSINK :: 0x00001000
  371. RIDEV_DEVNOTIFY :: 0x00002000
  372. RID_HEADER :: 0x10000005
  373. RID_INPUT :: 0x10000003
  374. RIM_TYPEMOUSE :: 0
  375. RIM_TYPEKEYBOARD :: 1
  376. RIM_TYPEHID :: 2
  377. MOUSE_MOVE_RELATIVE :: 0x00
  378. MOUSE_MOVE_ABSOLUTE :: 0x01
  379. MOUSE_VIRTUAL_DESKTOP :: 0x02
  380. MOUSE_ATTRIUBTTES_CHANGED :: 0x04
  381. MOUSE_MOVE_NOCOALESCE :: 0x08
  382. RI_MOUSE_BUTTON_1_DOWN :: 0x0001
  383. RI_MOUSE_LEFT_BUTTON_DOWNS :: RI_MOUSE_BUTTON_1_DOWN
  384. RI_MOUSE_BUTTON_1_UP :: 0x0002
  385. RI_MOUSE_LEFT_BUTTON_UP :: RI_MOUSE_BUTTON_1_UP
  386. RI_MOUSE_BUTTON_2_DOWN :: 0x0004
  387. RI_MOUSE_RIGHT_BUTTON_DOWN :: RI_MOUSE_BUTTON_2_DOWN
  388. RI_MOUSE_BUTTON_2_UP :: 0x0008
  389. RI_MOUSE_RIGHT_BUTTON_UP :: RI_MOUSE_BUTTON_2_UP
  390. RI_MOUSE_BUTTON_3_DOWN :: 0x0010
  391. RI_MOUSE_MIDDLE_BUTTON_DOWN :: RI_MOUSE_BUTTON_3_DOWN
  392. RI_MOUSE_BUTTON_3_UP :: 0x0020
  393. RI_MOUSE_MIDDLE_BUTTON_UP :: RI_MOUSE_BUTTON_3_UP
  394. RI_MOUSE_BUTTON_4_DOWN :: 0x0040
  395. RI_MOUSE_BUTTON_4_UP :: 0x0080
  396. RI_MOUSE_BUTTON_5_DOWN :: 0x0100
  397. RI_MOUSE_BUTTON_5_UP :: 0x0200
  398. RI_MOUSE_WHEEL :: 0x0400
  399. RI_MOUSE_HWHEEL :: 0x0800
  400. HID_USAGE_PAGE_GENERIC :: 0x01
  401. HID_USAGE_PAGE_GAME :: 0x05
  402. HID_USAGE_PAGE_LED :: 0x08
  403. HID_USAGE_PAGE_BUTTON :: 0x09
  404. HID_USAGE_GENERIC_POINTER :: 0x01
  405. HID_USAGE_GENERIC_MOUSE :: 0x02
  406. HID_USAGE_GENERIC_JOYSTICK :: 0x04
  407. HID_USAGE_GENERIC_GAMEPAD :: 0x05
  408. HID_USAGE_GENERIC_KEYBOARD :: 0x06
  409. HID_USAGE_GENERIC_KEYPAD :: 0x07
  410. HID_USAGE_GENERIC_MULTI_AXIS_CONTROLLER :: 0x08
  411. WINDOWPLACEMENT :: struct {
  412. length: UINT,
  413. flags: UINT,
  414. showCmd: UINT,
  415. ptMinPosition: POINT,
  416. ptMaxPosition: POINT,
  417. rcNormalPosition: RECT,
  418. }
  419. WINDOWINFO :: struct {
  420. cbSize: DWORD,
  421. rcWindow: RECT,
  422. rcClient: RECT,
  423. dwStyle: DWORD,
  424. dwExStyle: DWORD,
  425. dwWindowStatus: DWORD,
  426. cxWindowBorders: UINT,
  427. cyWindowBorders: UINT,
  428. atomWindowType: ATOM,
  429. wCreatorVersion: WORD,
  430. }
  431. PWINDOWINFO :: ^WINDOWINFO
  432. DRAWTEXTPARAMS :: struct {
  433. cbSize : UINT ,
  434. iTabLength: int ,
  435. iLeftMargin: int ,
  436. iRightMargin: int ,
  437. uiLengthDrawn: UINT ,
  438. }
  439. PDRAWTEXTPARAMS :: ^DRAWTEXTPARAMS
  440. DrawTextFormat :: enum UINT {
  441. DT_TOP = 0x00000000,
  442. DT_LEFT = 0x00000000,
  443. DT_CENTER = 0x00000001,
  444. DT_RIGHT = 0x00000002,
  445. DT_VCENTER = 0x00000004,
  446. DT_BOTTOM = 0x00000008,
  447. DT_WORDBREAK = 0x00000010,
  448. DT_SINGLELINE = 0x00000020,
  449. DT_EXPANDTABS = 0x00000040,
  450. DT_TABSTOP = 0x00000080,
  451. DT_NOCLIP = 0x00000100,
  452. DT_EXTERNALLEADING = 0x00000200,
  453. DT_CALCRECT = 0x00000400,
  454. DT_NOPREFIX = 0x00000800,
  455. DT_INTERNAL = 0x00001000,
  456. DT_EDITCONTROL = 0x00002000,
  457. DT_PATH_ELLIPSIS = 0x00004000,
  458. DT_END_ELLIPSIS = 0x00008000,
  459. DT_MODIFYSTRING = 0x00010000,
  460. DT_RTLREADING = 0x00020000,
  461. DT_WORD_ELLIPSIS = 0x00040000,
  462. DT_NOFULLWIDTHCHARBREAK = 0x00080000,
  463. DT_HIDEPREFIX = 0x00100000,
  464. DT_PREFIXONLY = 0x00200000,
  465. }
  466. RedrawWindowFlags :: enum UINT {
  467. RDW_INVALIDATE = 0x0001,
  468. RDW_INTERNALPAINT = 0x0002,
  469. RDW_ERASE = 0x0004,
  470. RDW_VALIDATE = 0x0008,
  471. RDW_NOINTERNALPAINT = 0x0010,
  472. RDW_NOERASE = 0x0020,
  473. RDW_NOCHILDREN = 0x0040,
  474. RDW_ALLCHILDREN = 0x0080,
  475. RDW_UPDATENOW = 0x0100,
  476. RDW_ERASENOW = 0x0200,
  477. RDW_FRAME = 0x0400,
  478. RDW_NOFRAME = 0x0800,
  479. }