user32.odin 20 KB

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