user32.odin 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  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(hInstance: HINSTANCE, lpszClass: LPCWSTR, lpwcx: ^WNDCLASSEXW) -> BOOL ---
  9. GetClassLongW :: proc(hWnd: HWND, nIndex: INT) -> DWORD ---
  10. SetClassLongW :: proc(hWnd: HWND, nIndex: INT, dwNewLong: LONG) -> DWORD ---
  11. GetWindowLongW :: proc(hWnd: HWND, nIndex: INT) -> LONG ---
  12. SetWindowLongW :: proc(hWnd: HWND, nIndex: INT, dwNewLong: LONG) -> LONG ---
  13. GetClassNameW :: proc(hWnd: HWND, lpClassName: LPWSTR, nMaxCount: INT) -> INT ---
  14. GetParent :: proc(hWnd: HWND) -> HWND ---
  15. SetWinEventHook :: proc(
  16. eventMin, eventMax: DWORD,
  17. hmodWinEventProc: HMODULE,
  18. pfnWinEvenProc: WINEVENTPROC,
  19. idProcess, idThread: DWORD,
  20. dwFlags: WinEventFlags,
  21. ) -> HWINEVENTHOOK ---
  22. IsChild :: proc(hWndParent, hWnd: HWND) -> BOOL ---
  23. RegisterClassW :: proc(lpWndClass: ^WNDCLASSW) -> ATOM ---
  24. RegisterClassExW :: proc(^WNDCLASSEXW) -> ATOM ---
  25. UnregisterClassW :: proc(lpClassName: LPCWSTR, hInstance: HINSTANCE) -> BOOL ---
  26. CreateWindowExW :: proc(
  27. dwExStyle: DWORD,
  28. lpClassName: LPCWSTR,
  29. lpWindowName: LPCWSTR,
  30. dwStyle: DWORD,
  31. X, Y, nWidth, nHeight: INT,
  32. hWndParent: HWND,
  33. hMenu: HMENU,
  34. hInstance: HINSTANCE,
  35. lpParam: LPVOID,
  36. ) -> HWND ---
  37. DestroyWindow :: proc(hWnd: HWND) -> BOOL ---
  38. ShowWindow :: proc(hWnd: HWND, nCmdShow: INT) -> BOOL ---
  39. IsWindow :: proc(hWnd: HWND) -> BOOL ---
  40. IsWindowVisible :: proc(hwnd: HWND) -> BOOL ---
  41. IsWindowEnabled :: proc(hwnd: HWND) -> BOOL ---
  42. IsIconic :: proc(hwnd: HWND) -> BOOL ---
  43. BringWindowToTop :: proc(hWnd: HWND) -> BOOL ---
  44. GetTopWindow :: proc(hWnd: HWND) -> HWND ---
  45. SetForegroundWindow :: proc(hWnd: HWND) -> BOOL ---
  46. GetForegroundWindow :: proc() -> HWND ---
  47. GetDesktopWindow :: 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. SetParent :: proc(hWndChild: HWND, hWndNewParent: HWND) -> HWND ---
  53. SetPropW :: proc(hWnd: HWND, lpString: LPCWSTR, hData: HANDLE) -> BOOL ---
  54. GetPropW :: proc(hWnd: HWND, lpString: LPCWSTR) -> HANDLE ---
  55. RemovePropW :: proc(hWnd: HWND, lpString: LPCWSTR) -> HANDLE ---
  56. EnumPropsW :: proc(hWnd: HWND, lpEnumFunc: PROPENUMPROCW) -> INT ---
  57. EnumPropsExW :: proc(hWnd: HWND, lpEnumFunc: PROPENUMPROCW, lParam: LPARAM) -> INT ---
  58. GetMessageW :: proc(lpMsg: ^MSG, hWnd: HWND, wMsgFilterMin: UINT, wMsgFilterMax: UINT) -> BOOL ---
  59. TranslateMessage :: proc(lpMsg: ^MSG) -> BOOL ---
  60. DispatchMessageW :: proc(lpMsg: ^MSG) -> LRESULT ---
  61. WaitMessage :: proc() -> BOOL ---
  62. MsgWaitForMultipleObjects :: proc(nCount: DWORD, pHandles: ^HANDLE, fWaitAll: BOOL, dwMilliseconds: DWORD, dwWakeMask: DWORD) -> DWORD ---
  63. PeekMessageA :: proc(lpMsg: ^MSG, hWnd: HWND, wMsgFilterMin: UINT, wMsgFilterMax: UINT, wRemoveMsg: UINT) -> BOOL ---
  64. PeekMessageW :: proc(lpMsg: ^MSG, hWnd: HWND, wMsgFilterMin: UINT, wMsgFilterMax: UINT, wRemoveMsg: UINT) -> BOOL ---
  65. PostMessageA :: proc(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> BOOL ---
  66. PostMessageW :: proc(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> BOOL ---
  67. SendMessageA :: proc(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> LRESULT ---
  68. SendMessageW :: proc(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> LRESULT ---
  69. PostThreadMessageA :: proc(idThread: DWORD, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> BOOL ---
  70. PostThreadMessageW :: proc(idThread: DWORD, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> BOOL ---
  71. PostQuitMessage :: proc(nExitCode: INT) ---
  72. GetQueueStatus :: proc(flags: UINT) -> DWORD ---
  73. DefWindowProcA :: proc(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> LRESULT ---
  74. DefWindowProcW :: proc(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> LRESULT ---
  75. FindWindowA :: proc(lpClassName: LPCSTR, lpWindowName: LPCSTR) -> HWND ---
  76. FindWindowW :: proc(lpClassName: LPCWSTR, lpWindowName: LPCWSTR) -> HWND ---
  77. FindWindowExA :: proc(hWndParent: HWND, hWndChildAfter: HWND, lpszClass: LPCSTR, lpszWindow: LPCSTR) -> HWND ---
  78. FindWindowExW :: proc(hWndParent: HWND, hWndChildAfter: HWND, lpszClass: LPCWSTR, lpszWindow: LPCWSTR) -> HWND ---
  79. LoadIconA :: proc(hInstance: HINSTANCE, lpIconName: LPCSTR) -> HICON ---
  80. LoadIconW :: proc(hInstance: HINSTANCE, lpIconName: LPCWSTR) -> HICON ---
  81. GetIconInfoExW :: proc(hIcon: HICON, piconinfo: PICONINFOEXW) -> BOOL ---
  82. LoadCursorA :: proc(hInstance: HINSTANCE, lpCursorName: LPCSTR) -> HCURSOR ---
  83. LoadCursorW :: proc(hInstance: HINSTANCE, lpCursorName: LPCWSTR) -> HCURSOR ---
  84. LoadImageW :: proc(hInst: HINSTANCE, name: LPCWSTR, type: UINT, cx, cy: INT, fuLoad: UINT) -> HANDLE ---
  85. CreateIcon :: proc(hInstance: HINSTANCE, nWidth, nHeight: INT, cPlanes: BYTE, cBitsPixel: BYTE, lpbANDbits: PBYTE, lpbXORbits: PBYTE) -> HICON ---
  86. CreateIconFromResource :: proc(presbits: PBYTE, dwResSize: DWORD, fIcon: BOOL, dwVer: DWORD) -> HICON ---
  87. DestroyIcon :: proc(hIcon: HICON) -> BOOL ---
  88. DrawIcon :: proc(hDC: HDC, X, Y: INT, hIcon: HICON) -> BOOL ---
  89. CreateCursor :: proc(hInst: HINSTANCE, xHotSpot, yHotSpot, nWidth, nHeight: INT, pvANDPlane: PVOID, pvXORPlane: PVOID) -> HCURSOR ---
  90. DestroyCursor :: proc(hCursor: HCURSOR) -> BOOL ---
  91. GetWindowRect :: proc(hWnd: HWND, lpRect: LPRECT) -> BOOL ---
  92. GetClientRect :: proc(hWnd: HWND, lpRect: LPRECT) -> BOOL ---
  93. ClientToScreen :: proc(hWnd: HWND, lpPoint: LPPOINT) -> BOOL ---
  94. ScreenToClient :: proc(hWnd: HWND, lpPoint: LPPOINT) -> BOOL ---
  95. SetWindowPos :: proc(hWnd: HWND, hWndInsertAfter: HWND, X, Y, cx, cy: INT, uFlags: UINT) -> BOOL ---
  96. MoveWindow :: proc(hWnd: HWND, X, Y, hWidth, hHeight: INT, bRepaint: BOOL) -> BOOL ---
  97. GetSystemMetrics :: proc(nIndex: INT) -> INT ---
  98. AdjustWindowRect :: proc(lpRect: LPRECT, dwStyle: DWORD, bMenu: BOOL) -> BOOL ---
  99. AdjustWindowRectEx :: proc(lpRect: LPRECT, dwStyle: DWORD, bMenu: BOOL, dwExStyle: DWORD) -> BOOL ---
  100. AdjustWindowRectExForDpi :: proc(lpRect: LPRECT, dwStyle: DWORD, bMenu: BOOL, dwExStyle: DWORD, dpi: UINT) -> BOOL ---
  101. SystemParametersInfoW :: proc(uiAction, uiParam: UINT, pvParam: PVOID, fWinIni: UINT) -> BOOL ---
  102. GetMonitorInfoW :: proc(hMonitor: HMONITOR, lpmi: LPMONITORINFO) -> BOOL ---
  103. GetWindowDC :: proc(hWnd: HWND) -> HDC ---
  104. GetDC :: proc(hWnd: HWND) -> HDC ---
  105. GetDCEx :: proc(hWnd: HWND, hrgnClip: HRGN, flags: DWORD) -> HDC ---
  106. ReleaseDC :: proc(hWnd: HWND, hDC: HDC) -> INT ---
  107. GetDlgCtrlID :: proc(hWnd: HWND) -> INT ---
  108. GetDlgItem :: proc(hDlg: HWND, nIDDlgItem: INT) -> HWND ---
  109. CreateMenu :: proc() -> HMENU ---
  110. CreatePopupMenu :: proc() -> HMENU ---
  111. DeleteMenu :: proc(hMenu: HMENU, uPosition: UINT, uFlags: UINT) -> BOOL ---
  112. DestroyMenu :: proc(hMenu: HMENU) -> BOOL ---
  113. InsertMenuW :: proc(hMenu: HMENU, uPosition: UINT, uFlags: UINT, uIDNewItem: UINT_PTR, lpNewItem: LPCWSTR) -> BOOL ---
  114. AppendMenuW :: proc(hMenu: HMENU, uFlags: UINT, uIDNewItem: UINT_PTR, lpNewItem: LPCWSTR) -> BOOL ---
  115. GetMenu :: proc(hWnd: HWND) -> HMENU ---
  116. SetMenu :: proc(hWnd: HWND, hMenu: HMENU) -> BOOL ---
  117. TrackPopupMenu :: proc(hMenu: HMENU, uFlags: UINT, x, y: INT, nReserved: INT, hWnd: HWND, prcRect: ^RECT) -> BOOL ---
  118. RegisterWindowMessageW :: proc(lpString: LPCWSTR) -> UINT ---
  119. CreateAcceleratorTableW :: proc(paccel: LPACCEL, cAccel: INT) -> HACCEL ---
  120. DestroyAcceleratorTable :: proc(hAccel: HACCEL) -> BOOL ---
  121. LoadAcceleratorsW :: proc(hInstance: HINSTANCE, lpTableName: LPCWSTR) -> HACCEL ---
  122. TranslateAcceleratorW :: proc(hWnd: HWND, hAccTable: HACCEL, lpMsg: LPMSG) -> INT ---
  123. CopyAcceleratorTableW :: proc(hAccelSrc: HACCEL, lpAccelDst: LPACCEL, cAccelEntries: INT) -> INT ---
  124. InsertMenuItemW :: proc(hmenu: HMENU, item: UINT, fByPosition: BOOL, lpmi: LPMENUITEMINFOW) -> BOOL ---
  125. GetMenuItemInfoW :: proc(hmenu: HMENU, item: UINT, fByPosition: BOOL, lpmii: LPMENUITEMINFOW) -> BOOL ---
  126. SetMenuItemInfoW :: proc(hmenu: HMENU, item: UINT, fByPositon: BOOL, lpmii: LPMENUITEMINFOW) -> BOOL ---
  127. GetMenuDefaultItem :: proc(hMenu: HMENU, fByPos: UINT, gmdiFlags: UINT) -> UINT ---
  128. SetMenuDefaultItem :: proc(hMenu: HMENU, uItem: UINT, fByPos: UINT) -> BOOL ---
  129. GetMenuItemRect :: proc(hWnd: HWND, hMenu: HMENU, uItem: UINT, lprcItem: LPRECT) -> c_int ---
  130. GetUpdateRect :: proc(hWnd: HWND, lpRect: LPRECT, bErase: BOOL) -> BOOL ---
  131. ValidateRect :: proc(hWnd: HWND, lpRect: ^RECT) -> BOOL ---
  132. InvalidateRect :: proc(hWnd: HWND, lpRect: ^RECT, bErase: BOOL) -> BOOL ---
  133. BeginPaint :: proc(hWnd: HWND, lpPaint: ^PAINTSTRUCT) -> HDC ---
  134. EndPaint :: proc(hWnd: HWND, lpPaint: ^PAINTSTRUCT) -> BOOL ---
  135. GetCapture :: proc() -> HWND ---
  136. SetCapture :: proc(hWnd: HWND) -> HWND ---
  137. ReleaseCapture :: proc() -> BOOL ---
  138. TrackMouseEvent :: proc(lpEventTrack: LPTRACKMOUSEEVENT) -> BOOL ---
  139. GetKeyState :: proc(nVirtKey: INT) -> SHORT ---
  140. GetAsyncKeyState :: proc(vKey: INT) -> SHORT ---
  141. GetKeyboardState :: proc(lpKeyState: PBYTE) -> BOOL ---
  142. MapVirtualKeyW :: proc(uCode: UINT, uMapType: UINT) -> UINT ---
  143. ToUnicode :: proc(nVirtKey: UINT, wScanCode: UINT, lpKeyState: ^BYTE, pwszBuff: LPWSTR, cchBuff: INT, wFlags: UINT) -> INT ---
  144. SetWindowsHookExW :: proc(idHook: INT, lpfn: HOOKPROC, hmod: HINSTANCE, dwThreadId: DWORD) -> HHOOK ---
  145. UnhookWindowsHookEx :: proc(hhk: HHOOK) -> BOOL ---
  146. CallNextHookEx :: proc(hhk: HHOOK, nCode: INT, wParam: WPARAM, lParam: LPARAM) -> LRESULT ---
  147. SetTimer :: proc(hWnd: HWND, nIDEvent: UINT_PTR, uElapse: UINT, lpTimerFunc: TIMERPROC) -> UINT_PTR ---
  148. KillTimer :: proc(hWnd: HWND, uIDEvent: UINT_PTR) -> BOOL ---
  149. // MessageBoxA :: proc(hWnd: HWND, lpText: LPCSTR, lpCaption: LPCSTR, uType: UINT) -> INT ---
  150. MessageBoxW :: proc(hWnd: HWND, lpText: LPCWSTR, lpCaption: LPCWSTR, uType: UINT) -> INT ---
  151. // MessageBoxExA :: proc(hWnd: HWND, lpText: LPCSTR, lpCaption: LPCSTR, uType: UINT, wLanguageId: WORD) -> INT ---
  152. MessageBoxExW :: proc(hWnd: HWND, lpText: LPCWSTR, lpCaption: LPCWSTR, uType: UINT, wLanguageId: WORD) -> INT ---
  153. ClipCursor :: proc(lpRect: LPRECT) -> BOOL ---
  154. GetCursorPos :: proc(lpPoint: LPPOINT) -> BOOL ---
  155. SetCursorPos :: proc(X, Y: INT) -> BOOL ---
  156. SetCursor :: proc(hCursor: HCURSOR) -> HCURSOR ---
  157. when !intrinsics.is_package_imported("raylib") {
  158. ShowCursor :: proc(bShow: BOOL) -> INT ---
  159. }
  160. EnumDisplayDevicesW :: proc (lpDevice: LPCWSTR, iDevNum: DWORD, lpDisplayDevice: PDISPLAY_DEVICEW, dwFlags: DWORD) -> BOOL ---
  161. EnumDisplaySettingsW :: proc(lpszDeviceName: LPCWSTR, iModeNum: DWORD, lpDevMode: ^DEVMODEW) -> BOOL ---
  162. MonitorFromPoint :: proc(pt: POINT, dwFlags: Monitor_From_Flags) -> HMONITOR ---
  163. MonitorFromRect :: proc(lprc: LPRECT, dwFlags: Monitor_From_Flags) -> HMONITOR ---
  164. MonitorFromWindow :: proc(hwnd: HWND, dwFlags: Monitor_From_Flags) -> HMONITOR ---
  165. EnumDisplayMonitors :: proc(hdc: HDC, lprcClip: LPRECT, lpfnEnum: Monitor_Enum_Proc, dwData: LPARAM) -> BOOL ---
  166. EnumWindows :: proc(lpEnumFunc: Window_Enum_Proc, lParam: LPARAM) -> BOOL ---
  167. IsProcessDPIAware :: proc() -> BOOL ---
  168. SetProcessDPIAware :: proc() -> BOOL ---
  169. SetThreadDpiAwarenessContext :: proc(dpiContext: DPI_AWARENESS_CONTEXT) -> DPI_AWARENESS_CONTEXT ---
  170. GetThreadDpiAwarenessContext :: proc() -> DPI_AWARENESS_CONTEXT ---
  171. GetWindowDpiAwarenessContext :: proc(hwnd: HWND) -> DPI_AWARENESS_CONTEXT ---
  172. GetDpiFromDpiAwarenessContext :: proc(value: DPI_AWARENESS_CONTEXT) -> UINT ---
  173. GetDpiForWindow :: proc(hwnd: HWND) -> UINT ---
  174. SetProcessDpiAwarenessContext :: proc(value: DPI_AWARENESS_CONTEXT) -> BOOL ---
  175. BroadcastSystemMessageW :: proc(
  176. flags: DWORD,
  177. lpInfo: LPDWORD,
  178. Msg: UINT,
  179. wParam: WPARAM,
  180. lParam: LPARAM,
  181. ) -> c_long ---
  182. BroadcastSystemMessageExW :: proc(
  183. flags: DWORD,
  184. lpInfo: LPDWORD,
  185. Msg: UINT,
  186. wParam: WPARAM,
  187. lParam: LPARAM,
  188. pbsmInfo: PBSMINFO,
  189. ) -> c_long ---
  190. SendMessageTimeoutW :: proc(
  191. hWnd: HWND,
  192. Msg: UINT,
  193. wParam: WPARAM,
  194. lParam: LPARAM,
  195. fuFlags: UINT,
  196. uTimeout: UINT,
  197. lpdwResult: PDWORD_PTR,
  198. ) -> LRESULT ---
  199. GetSysColor :: proc(nIndex: INT) -> DWORD ---
  200. GetSysColorBrush :: proc(nIndex: INT) -> HBRUSH ---
  201. SetSysColors :: proc(cElements: INT, lpaElements: ^INT, lpaRgbValues: ^COLORREF) -> BOOL ---
  202. MessageBeep :: proc(uType: UINT) -> BOOL ---
  203. IsDialogMessageW :: proc(hDlg: HWND, lpMsg: LPMSG) -> BOOL ---
  204. GetWindowTextLengthW :: proc(hWnd: HWND) -> INT ---
  205. GetWindowTextW :: proc(hWnd: HWND, lpString: LPWSTR, nMaxCount: INT) -> INT ---
  206. SetWindowTextW :: proc(hWnd: HWND, lpString: LPCWSTR) -> BOOL ---
  207. CallWindowProcW :: proc(lpPrevWndFunc: WNDPROC, hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> LRESULT ---
  208. EnableWindow :: proc(hWnd: HWND, bEnable: BOOL) -> BOOL ---
  209. DefRawInputProc :: proc(paRawInput: ^PRAWINPUT, nInput: INT, cbSizeHeader: UINT) -> LRESULT ---
  210. GetRawInputBuffer :: proc(pRawInput: PRAWINPUT, pcbSize: PUINT, cbSizeHeader: UINT) -> UINT ---
  211. GetRawInputData :: proc(hRawInput: HRAWINPUT, uiCommand: UINT, pData: LPVOID, pcbSize: PUINT, cbSizeHeader: UINT) -> UINT ---
  212. GetRawInputDeviceInfoW :: proc(hDevice: HANDLE, uiCommand: UINT, pData: LPVOID, pcbSize: PUINT) -> UINT ---
  213. GetRawInputDeviceList :: proc(pRawInputDeviceList: PRAWINPUTDEVICELIST, puiNumDevices: PUINT, cbSize: UINT) -> UINT ---
  214. GetRegisteredRawInputDevices :: proc(pRawInputDevices: PRAWINPUTDEVICE, puiNumDevices: PUINT, cbSize: UINT) -> UINT ---
  215. RegisterRawInputDevices :: proc(pRawInputDevices: PCRAWINPUTDEVICE, uiNumDevices: UINT, cbSize: UINT) -> BOOL ---
  216. SendInput :: proc(cInputs: UINT, pInputs: [^]INPUT, cbSize: INT) -> UINT ---
  217. SetLayeredWindowAttributes :: proc(hWnd: HWND, crKey: COLORREF, bAlpha: BYTE, dwFlags: DWORD) -> BOOL ---
  218. FillRect :: proc(hDC: HDC, lprc: ^RECT, hbr: HBRUSH) -> int ---
  219. EqualRect :: proc(lprc1, lprc2: ^RECT) -> BOOL ---
  220. OffsetRect :: proc(lprc1: ^RECT, dx, dy: INT) -> BOOL ---
  221. InflateRect :: proc(lprc1: ^RECT, dx, dy: INT) -> BOOL ---
  222. IntersectRect :: proc(lprcDst, lprcSrc1, lprcSrc2: ^RECT) -> BOOL ---
  223. SubtractRect :: proc(lprcDst, lprcSrc1, lprcSrc2: ^RECT) -> BOOL ---
  224. UnionRect :: proc(lprcDst, lprcSrc1, lprcSrc2: ^RECT) -> BOOL ---
  225. IsRectEmpty :: proc(lprc: ^RECT) -> BOOL ---
  226. SetRectEmpty :: proc(lprc: ^RECT) -> BOOL ---
  227. CopyRect :: proc(lprcDst, lprcSrc: ^RECT) -> BOOL ---
  228. GetWindowInfo :: proc(hwnd: HWND, pwi: PWINDOWINFO) -> BOOL ---
  229. GetWindowPlacement :: proc(hWnd: HWND, lpwndpl: ^WINDOWPLACEMENT) -> BOOL ---
  230. SetWindowPlacement :: proc(hwnd: HWND, lpwndpl: ^WINDOWPLACEMENT) -> BOOL ---
  231. SetWindowRgn :: proc(hWnd: HWND, hRgn: HRGN, bRedraw: BOOL) -> int ---
  232. CreateRectRgnIndirect :: proc(lprect: ^RECT) -> HRGN ---
  233. GetSystemMetricsForDpi :: proc(nIndex: int, dpi: UINT) -> int ---
  234. GetCursorInfo :: proc(pci: PCURSORINFO) -> BOOL ---
  235. GetSystemMenu :: proc(hWnd: HWND, bRevert: BOOL) -> HMENU ---
  236. EnableMenuItem :: proc(hMenu: HMENU, uIDEnableItem: UINT, uEnable: UINT) -> BOOL ---
  237. MenuItemFromPoint :: proc(hWnd: HWND, hMenu: HMENU, ptScreen: POINT) -> INT ---
  238. DrawTextW :: proc(hdc: HDC, lpchText: LPCWSTR, cchText: INT, lprc: LPRECT, format: DrawTextFormat) -> INT ---
  239. DrawTextExW :: proc(hdc: HDC, lpchText: LPCWSTR, cchText: INT, lprc: LPRECT, format: DrawTextFormat, lpdtp: PDRAWTEXTPARAMS) -> INT ---
  240. GetLocaleInfoEx :: proc(lpLocaleName: LPCWSTR, LCType: LCTYPE, lpLCData: LPWSTR, cchData: INT) -> INT ---
  241. IsValidLocaleName :: proc(lpLocaleName: LPCWSTR) -> BOOL ---
  242. ResolveLocaleName :: proc(lpNameToResolve: LPCWSTR, lpLocaleName: LPWSTR, cchLocaleName: INT) -> INT ---
  243. IsValidCodePage :: proc(CodePage: UINT) -> BOOL ---
  244. GetACP :: proc() -> CODEPAGE ---
  245. GetCPInfoExW :: proc(CodePage: CODEPAGE, dwFlags: DWORD, lpCPInfoEx: LPCPINFOEXW) -> BOOL ---
  246. GetProcessWindowStation :: proc() -> HWINSTA ---
  247. GetUserObjectInformationW :: proc(hObj: HANDLE, nIndex: GetUserObjectInformationFlags, pvInfo: PVOID, nLength: DWORD, lpnLengthNeeded: LPDWORD) -> BOOL ---
  248. }
  249. CreateWindowW :: #force_inline proc "system" (
  250. lpClassName: LPCTSTR,
  251. lpWindowName: LPCTSTR,
  252. dwStyle: DWORD,
  253. X: INT,
  254. Y: INT,
  255. nWidth: INT,
  256. nHeight: INT,
  257. hWndParent: HWND,
  258. hMenu: HMENU,
  259. hInstance: HINSTANCE,
  260. lpParam: LPVOID,
  261. ) -> HWND {
  262. return CreateWindowExW(
  263. 0,
  264. lpClassName,
  265. lpWindowName,
  266. dwStyle,
  267. X,
  268. Y,
  269. nWidth,
  270. nHeight,
  271. hWndParent,
  272. hMenu,
  273. hInstance,
  274. lpParam,
  275. )
  276. }
  277. when ODIN_ARCH == .amd64 {
  278. @(default_calling_convention="system")
  279. foreign user32 {
  280. GetClassLongPtrW :: proc(hWnd: HWND, nIndex: INT) -> ULONG_PTR ---
  281. SetClassLongPtrW :: proc(hWnd: HWND, nIndex: INT, dwNewLong: LONG_PTR) -> ULONG_PTR ---
  282. GetWindowLongPtrW :: proc(hWnd: HWND, nIndex: INT) -> LONG_PTR ---
  283. SetWindowLongPtrW :: proc(hWnd: HWND, nIndex: INT, dwNewLong: LONG_PTR) -> LONG_PTR ---
  284. }
  285. } else when ODIN_ARCH == .i386 {
  286. GetClassLongPtrW :: GetClassLongW
  287. SetClassLongPtrW :: SetClassLongW
  288. GetWindowLongPtrW :: GetWindowLongW
  289. SetWindowLongPtrW :: SetWindowLongW
  290. }
  291. GET_SC_WPARAM :: #force_inline proc "contextless" (wParam: WPARAM) -> INT {
  292. return INT(wParam) & 0xFFF0
  293. }
  294. GET_WHEEL_DELTA_WPARAM :: #force_inline proc "contextless" (wParam: WPARAM) -> c_short {
  295. return cast(c_short)HIWORD(cast(DWORD)wParam)
  296. }
  297. GET_KEYSTATE_WPARAM :: #force_inline proc "contextless" (wParam: WPARAM) -> WORD {
  298. return LOWORD(cast(DWORD)wParam)
  299. }
  300. GET_NCHITTEST_WPARAM :: #force_inline proc "contextless" (wParam: WPARAM) -> c_short {
  301. return cast(c_short)LOWORD(cast(DWORD)wParam)
  302. }
  303. GET_XBUTTON_WPARAM :: #force_inline proc "contextless" (wParam: WPARAM) -> WORD {
  304. return HIWORD(cast(DWORD)wParam)
  305. }
  306. GET_RAWINPUT_CODE_WPARAM :: #force_inline proc "contextless" (wParam: WPARAM) -> BYTE {
  307. return BYTE(wParam) & 0xFF
  308. }
  309. MAKEINTRESOURCEW :: #force_inline proc "contextless" (#any_int i: int) -> LPWSTR {
  310. return cast(LPWSTR)uintptr(WORD(i))
  311. }
  312. Monitor_From_Flags :: enum DWORD {
  313. MONITOR_DEFAULTTONULL = 0x00000000, // Returns NULL
  314. MONITOR_DEFAULTTOPRIMARY = 0x00000001, // Returns a handle to the primary display monitor
  315. MONITOR_DEFAULTTONEAREST = 0x00000002, // Returns a handle to the display monitor that is nearest to the window
  316. }
  317. Monitor_Enum_Proc :: #type proc "system" (HMONITOR, HDC, LPRECT, LPARAM) -> BOOL
  318. Window_Enum_Proc :: #type proc "system" (HWND, LPARAM) -> BOOL
  319. USER_DEFAULT_SCREEN_DPI :: 96
  320. DPI_AWARENESS_CONTEXT :: distinct HANDLE
  321. DPI_AWARENESS_CONTEXT_UNAWARE :: DPI_AWARENESS_CONTEXT(~uintptr(0)) // -1
  322. DPI_AWARENESS_CONTEXT_SYSTEM_AWARE :: DPI_AWARENESS_CONTEXT(~uintptr(1)) // -2
  323. DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE :: DPI_AWARENESS_CONTEXT(~uintptr(2)) // -3
  324. DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 :: DPI_AWARENESS_CONTEXT(~uintptr(3)) // -4
  325. DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED :: DPI_AWARENESS_CONTEXT(~uintptr(4)) // -5
  326. RAWINPUTHEADER :: struct {
  327. dwType: DWORD,
  328. dwSize: DWORD,
  329. hDevice: HANDLE,
  330. wParam: WPARAM,
  331. }
  332. RAWHID :: struct {
  333. dwSizeHid: DWORD,
  334. dwCount: DWORD,
  335. bRawData: [1]BYTE,
  336. }
  337. RAWMOUSE :: struct {
  338. usFlags: USHORT,
  339. using DUMMYUNIONNAME: struct #raw_union {
  340. ulButtons: ULONG,
  341. using DUMMYSTRUCTNAME: struct {
  342. usButtonFlags: USHORT,
  343. usButtonData: USHORT,
  344. },
  345. },
  346. ulRawButtons: ULONG,
  347. lLastX: LONG,
  348. lLastY: LONG,
  349. ulExtraInformation: ULONG,
  350. }
  351. RAWKEYBOARD :: struct {
  352. MakeCode: USHORT,
  353. Flags: USHORT,
  354. Rserved: USHORT,
  355. VKey: USHORT,
  356. Message: UINT,
  357. ExtraInformation: ULONG,
  358. }
  359. RAWINPUT :: struct {
  360. header: RAWINPUTHEADER,
  361. data: struct #raw_union {
  362. mouse: RAWMOUSE,
  363. keyboard: RAWKEYBOARD,
  364. hid: RAWHID,
  365. },
  366. }
  367. PRAWINPUT :: ^RAWINPUT
  368. HRAWINPUT :: distinct LPARAM
  369. RAWINPUTDEVICE :: struct {
  370. usUsagePage: USHORT,
  371. usUsage: USHORT,
  372. dwFlags: DWORD,
  373. hwndTarget: HWND,
  374. }
  375. PRAWINPUTDEVICE :: ^RAWINPUTDEVICE
  376. PCRAWINPUTDEVICE :: PRAWINPUTDEVICE
  377. RAWINPUTDEVICELIST :: struct {
  378. hDevice: HANDLE,
  379. dwType: DWORD,
  380. }
  381. PRAWINPUTDEVICELIST :: ^RAWINPUTDEVICELIST
  382. RID_DEVICE_INFO_HID :: struct {
  383. dwVendorId: DWORD,
  384. dwProductId: DWORD,
  385. dwVersionNumber: DWORD,
  386. usUsagePage: USHORT,
  387. usUsage: USHORT,
  388. }
  389. RID_DEVICE_INFO_KEYBOARD :: struct {
  390. dwType: DWORD,
  391. dwSubType: DWORD,
  392. dwKeyboardMode: DWORD,
  393. dwNumberOfFunctionKeys: DWORD,
  394. dwNumberOfIndicators: DWORD,
  395. dwNumberOfKeysTotal: DWORD,
  396. }
  397. RID_DEVICE_INFO_MOUSE :: struct {
  398. dwId: DWORD,
  399. dwNumberOfButtons: DWORD,
  400. dwSampleRate: DWORD,
  401. fHasHorizontalWheel: BOOL,
  402. }
  403. RID_DEVICE_INFO :: struct {
  404. cbSize: DWORD,
  405. dwType: DWORD,
  406. using DUMMYUNIONNAME: struct #raw_union {
  407. mouse: RID_DEVICE_INFO_MOUSE,
  408. keyboard: RID_DEVICE_INFO_KEYBOARD,
  409. hid: RID_DEVICE_INFO_HID,
  410. },
  411. }
  412. RIDEV_REMOVE :: 0x00000001
  413. RIDEV_EXCLUDE :: 0x00000010
  414. RIDEV_PAGEONLY :: 0x00000020
  415. RIDEV_NOLEGACY :: 0x00000030
  416. RIDEV_INPUTSINK :: 0x00000100
  417. RIDEV_CAPTUREMOUSE :: 0x00000200
  418. RIDEV_NOHOTKEYS :: 0x00000200
  419. RIDEV_APPKEYS :: 0x00000400
  420. RIDEV_EXINPUTSINK :: 0x00001000
  421. RIDEV_DEVNOTIFY :: 0x00002000
  422. RID_HEADER :: 0x10000005
  423. RID_INPUT :: 0x10000003
  424. RIDI_PREPARSEDDATA :: 0x20000005
  425. RIDI_DEVICENAME :: 0x20000007
  426. RIDI_DEVICEINFO :: 0x2000000b
  427. RIM_TYPEMOUSE :: 0
  428. RIM_TYPEKEYBOARD :: 1
  429. RIM_TYPEHID :: 2
  430. RI_KEY_MAKE :: 0
  431. RI_KEY_BREAK :: 1
  432. RI_KEY_E0 :: 2
  433. RI_KEY_E1 :: 4
  434. RI_KEY_TERMSRV_SET_LED :: 8
  435. RI_KEY_TERMSRV_SHADOW :: 0x10
  436. MOUSE_MOVE_RELATIVE :: 0x00
  437. MOUSE_MOVE_ABSOLUTE :: 0x01
  438. MOUSE_VIRTUAL_DESKTOP :: 0x02
  439. MOUSE_ATTRIUBTTES_CHANGED :: 0x04
  440. MOUSE_MOVE_NOCOALESCE :: 0x08
  441. RI_MOUSE_BUTTON_1_DOWN :: 0x0001
  442. RI_MOUSE_LEFT_BUTTON_DOWNS :: RI_MOUSE_BUTTON_1_DOWN
  443. RI_MOUSE_BUTTON_1_UP :: 0x0002
  444. RI_MOUSE_LEFT_BUTTON_UP :: RI_MOUSE_BUTTON_1_UP
  445. RI_MOUSE_BUTTON_2_DOWN :: 0x0004
  446. RI_MOUSE_RIGHT_BUTTON_DOWN :: RI_MOUSE_BUTTON_2_DOWN
  447. RI_MOUSE_BUTTON_2_UP :: 0x0008
  448. RI_MOUSE_RIGHT_BUTTON_UP :: RI_MOUSE_BUTTON_2_UP
  449. RI_MOUSE_BUTTON_3_DOWN :: 0x0010
  450. RI_MOUSE_MIDDLE_BUTTON_DOWN :: RI_MOUSE_BUTTON_3_DOWN
  451. RI_MOUSE_BUTTON_3_UP :: 0x0020
  452. RI_MOUSE_MIDDLE_BUTTON_UP :: RI_MOUSE_BUTTON_3_UP
  453. RI_MOUSE_BUTTON_4_DOWN :: 0x0040
  454. RI_MOUSE_BUTTON_4_UP :: 0x0080
  455. RI_MOUSE_BUTTON_5_DOWN :: 0x0100
  456. RI_MOUSE_BUTTON_5_UP :: 0x0200
  457. RI_MOUSE_WHEEL :: 0x0400
  458. RI_MOUSE_HWHEEL :: 0x0800
  459. WINDOWPLACEMENT :: struct {
  460. length: UINT,
  461. flags: UINT,
  462. showCmd: UINT,
  463. ptMinPosition: POINT,
  464. ptMaxPosition: POINT,
  465. rcNormalPosition: RECT,
  466. }
  467. WINDOWINFO :: struct {
  468. cbSize: DWORD,
  469. rcWindow: RECT,
  470. rcClient: RECT,
  471. dwStyle: DWORD,
  472. dwExStyle: DWORD,
  473. dwWindowStatus: DWORD,
  474. cxWindowBorders: UINT,
  475. cyWindowBorders: UINT,
  476. atomWindowType: ATOM,
  477. wCreatorVersion: WORD,
  478. }
  479. PWINDOWINFO :: ^WINDOWINFO
  480. CURSORINFO :: struct {
  481. cbSize: DWORD,
  482. flags: DWORD,
  483. hCursor: HCURSOR,
  484. ptScreenPos: POINT,
  485. }
  486. PCURSORINFO :: ^CURSORINFO
  487. DRAWTEXTPARAMS :: struct {
  488. cbSize: UINT,
  489. iTabLength: INT,
  490. iLeftMargin: INT,
  491. iRightMargin: INT,
  492. uiLengthDrawn: UINT,
  493. }
  494. PDRAWTEXTPARAMS :: ^DRAWTEXTPARAMS
  495. DrawTextFormat :: enum UINT {
  496. DT_TOP = 0x00000000,
  497. DT_LEFT = 0x00000000,
  498. DT_CENTER = 0x00000001,
  499. DT_RIGHT = 0x00000002,
  500. DT_VCENTER = 0x00000004,
  501. DT_BOTTOM = 0x00000008,
  502. DT_WORDBREAK = 0x00000010,
  503. DT_SINGLELINE = 0x00000020,
  504. DT_EXPANDTABS = 0x00000040,
  505. DT_TABSTOP = 0x00000080,
  506. DT_NOCLIP = 0x00000100,
  507. DT_EXTERNALLEADING = 0x00000200,
  508. DT_CALCRECT = 0x00000400,
  509. DT_NOPREFIX = 0x00000800,
  510. DT_INTERNAL = 0x00001000,
  511. DT_EDITCONTROL = 0x00002000,
  512. DT_PATH_ELLIPSIS = 0x00004000,
  513. DT_END_ELLIPSIS = 0x00008000,
  514. DT_MODIFYSTRING = 0x00010000,
  515. DT_RTLREADING = 0x00020000,
  516. DT_WORD_ELLIPSIS = 0x00040000,
  517. DT_NOFULLWIDTHCHARBREAK = 0x00080000,
  518. DT_HIDEPREFIX = 0x00100000,
  519. DT_PREFIXONLY = 0x00200000,
  520. }
  521. RedrawWindowFlags :: enum UINT {
  522. RDW_INVALIDATE = 0x0001,
  523. RDW_INTERNALPAINT = 0x0002,
  524. RDW_ERASE = 0x0004,
  525. RDW_VALIDATE = 0x0008,
  526. RDW_NOINTERNALPAINT = 0x0010,
  527. RDW_NOERASE = 0x0020,
  528. RDW_NOCHILDREN = 0x0040,
  529. RDW_ALLCHILDREN = 0x0080,
  530. RDW_UPDATENOW = 0x0100,
  531. RDW_ERASENOW = 0x0200,
  532. RDW_FRAME = 0x0400,
  533. RDW_NOFRAME = 0x0800,
  534. }
  535. GetUserObjectInformationFlags :: enum INT {
  536. UOI_FLAGS = 1,
  537. UOI_NAME = 2,
  538. UOI_TYPE = 3,
  539. UOI_USER_SID = 4,
  540. UOI_HEAPSIZE = 5,
  541. UOI_IO = 6,
  542. UOI_TIMERPROC_EXCEPTION_SUPPRESSION = 7,
  543. }
  544. USEROBJECTFLAGS :: struct {
  545. fInherit: BOOL,
  546. fReserved: BOOL,
  547. dwFlags: DWORD,
  548. }
  549. PROPENUMPROCW :: #type proc(unnamedParam1: HWND, unnamedParam2: LPCWSTR, unnamedParam3: HANDLE) -> BOOL
  550. PROPENUMPROCEXW :: #type proc(unnamedParam1: HWND, unnamedParam2: LPCWSTR, unnamedParam3: HANDLE, unnamedParam4: ULONG_PTR) -> BOOL
  551. RT_CURSOR :: LPWSTR(uintptr(0x00000001))
  552. RT_BITMAP :: LPWSTR(uintptr(0x00000002))
  553. RT_ICON :: LPWSTR(uintptr(0x00000003))
  554. RT_MENU :: LPWSTR(uintptr(0x00000004))
  555. RT_DIALOG :: LPWSTR(uintptr(0x00000005))
  556. RT_STRING :: LPWSTR(uintptr(0x00000006))
  557. RT_FONTDIR :: LPWSTR(uintptr(0x00000007))
  558. RT_FONT :: LPWSTR(uintptr(0x00000008))
  559. RT_ACCELERATOR :: LPWSTR(uintptr(0x00000009))
  560. RT_RCDATA :: LPWSTR(uintptr(0x0000000A))
  561. RT_MESSAGETABLE :: LPWSTR(uintptr(0x0000000B))
  562. RT_GROUP_CURSOR :: LPWSTR(uintptr(0x0000000C))
  563. RT_GROUP_ICON :: LPWSTR(uintptr(0x0000000E))
  564. RT_VERSION :: LPWSTR(uintptr(0x00000010))
  565. RT_DLGINCLUDE :: LPWSTR(uintptr(0x00000011))
  566. RT_PLUGPLAY :: LPWSTR(uintptr(0x00000013))
  567. RT_VXD :: LPWSTR(uintptr(0x00000014))
  568. RT_ANICURSOR :: LPWSTR(uintptr(0x00000015))
  569. RT_ANIICON :: LPWSTR(uintptr(0x00000016))
  570. RT_MANIFEST :: LPWSTR(uintptr(0x00000018))
  571. CREATEPROCESS_MANIFEST_RESOURCE_ID :: LPWSTR(uintptr(0x00000001))
  572. ISOLATIONAWARE_MANIFEST_RESOURCE_ID :: LPWSTR(uintptr(0x00000002))
  573. ISOLATIONAWARE_NOSTATICIMPORT_MANIFEST_RESOURCE_ID :: LPWSTR(uintptr(0x00000003))
  574. ISOLATIONPOLICY_MANIFEST_RESOURCE_ID :: LPWSTR(uintptr(0x00000004))
  575. ISOLATIONPOLICY_BROWSER_MANIFEST_RESOURCE_ID :: LPWSTR(uintptr(0x00000005))
  576. MINIMUM_RESERVED_MANIFEST_RESOURCE_ID :: LPWSTR(uintptr(0x00000001))
  577. MAXIMUM_RESERVED_MANIFEST_RESOURCE_ID :: LPWSTR(uintptr(0x00000010))
  578. ACCEL :: struct {
  579. /* Also called the flags field */
  580. fVirt: BYTE,
  581. key: WORD,
  582. cmd: WORD,
  583. }
  584. LPACCEL :: ^ACCEL
  585. MIIM_STATE :: 0x00000001
  586. MIIM_ID :: 0x00000002
  587. MIIM_SUBMENU :: 0x00000004
  588. MIIM_CHECKMARKS :: 0x00000008
  589. MIIM_TYPE :: 0x00000010
  590. MIIM_DATA :: 0x00000020
  591. MIIM_STRING :: 0x00000040
  592. MIIM_BITMAP :: 0x00000080
  593. MIIM_FTYPE :: 0x00000100
  594. MENUITEMINFOW :: struct {
  595. cbSize: UINT,
  596. fMask: UINT,
  597. fType: UINT, // used if MIIM_TYPE (4.0) or MIIM_FTYPE (>4.0)
  598. fState: UINT, // used if MIIM_STATE
  599. wID: UINT, // used if MIIM_ID
  600. hSubMenu: HMENU, // used if MIIM_SUBMENU
  601. hbmpChecked: HBITMAP, // used if MIIM_CHECKMARKS
  602. hbmpUnchecked: HBITMAP, // used if MIIM_CHECKMARKS
  603. dwItemData: ULONG_PTR, // used if MIIM_DATA
  604. dwTypeData: LPWSTR, // used if MIIM_TYPE (4.0) or MIIM_STRING (>4.0)
  605. cch: UINT, // used if MIIM_TYPE (4.0) or MIIM_STRING (>4.0)
  606. hbmpItem: HBITMAP, // used if MIIM_BITMAP
  607. }
  608. LPMENUITEMINFOW :: ^MENUITEMINFOW
  609. DISPLAY_DEVICEW :: struct {
  610. cb: DWORD,
  611. DeviceName: [32]WCHAR,
  612. DeviceString: [128]WCHAR,
  613. StateFlags: DWORD,
  614. DeviceID: [128]WCHAR,
  615. DeviceKey: [128]WCHAR,
  616. }
  617. PDISPLAY_DEVICEW :: ^DISPLAY_DEVICEW
  618. // OUTOFCONTEXT is the zero value, use {}
  619. WinEventFlags :: bit_set[WinEventFlag; DWORD]
  620. WinEventFlag :: enum DWORD {
  621. SKIPOWNTHREAD = 0,
  622. SKIPOWNPROCESS = 1,
  623. INCONTEXT = 2,
  624. }