user32.odin 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. // +build windows
  2. package sys_windows
  3. foreign import user32 "system:User32.lib"
  4. @(default_calling_convention="stdcall")
  5. foreign user32 {
  6. GetClassInfoA :: proc(hInstance: HINSTANCE, lpClassNAme: LPCSTR, lpWndClass: ^WNDCLASSA) -> BOOL ---
  7. GetClassInfoW :: proc(hInstance: HINSTANCE, lpClassNAme: LPCWSTR, lpWndClass: ^WNDCLASSW) -> BOOL ---
  8. GetClassInfoExA :: proc(hInsatnce: HINSTANCE, lpszClass: LPCSTR, lpwcx: ^WNDCLASSEXA) -> BOOL ---
  9. GetClassInfoExW :: proc(hInsatnce: HINSTANCE, lpszClass: LPCWSTR, lpwcx: ^WNDCLASSEXW) -> BOOL ---
  10. GetClassLongA :: proc(hWnd: HWND, nIndex: c_int) -> DWORD ---
  11. GetClassLongW :: proc(hWnd: HWND, nIndex: c_int) -> DWORD ---
  12. SetClassLongA :: proc(hWnd: HWND, nIndex: c_int, dwNewLong: LONG) -> DWORD ---
  13. SetClassLongW :: proc(hWnd: HWND, nIndex: c_int, dwNewLong: LONG) -> DWORD ---
  14. GetWindowLongA :: proc(hWnd: HWND, nIndex: c_int) -> LONG ---
  15. GetWindowLongW :: proc(hWnd: HWND, nIndex: c_int) -> LONG ---
  16. SetWindowLongA :: proc(hWnd: HWND, nIndex: c_int, dwNewLong: LONG) -> LONG ---
  17. SetWindowLongW :: proc(hWnd: HWND, nIndex: c_int, dwNewLong: LONG) -> LONG ---
  18. GetClassNameA :: proc(hWnd: HWND, lpClassName: LPSTR, nMaxCount: c_int) -> c_int ---
  19. GetClassNameW :: proc(hWnd: HWND, lpClassName: LPWSTR, nMaxCount: c_int) -> c_int ---
  20. RegisterClassA :: proc(lpWndClass: ^WNDCLASSA) -> ATOM ---
  21. RegisterClassW :: proc(lpWndClass: ^WNDCLASSW) -> ATOM ---
  22. RegisterClassExA :: proc(^WNDCLASSEXA) -> ATOM ---
  23. RegisterClassExW :: proc(^WNDCLASSEXW) -> ATOM ---
  24. CreateWindowExA :: proc(
  25. dwExStyle: DWORD,
  26. lpClassName: LPCSTR,
  27. lpWindowName: LPCSTR,
  28. dwStyle: DWORD,
  29. X: c_int,
  30. Y: c_int,
  31. nWidth: c_int,
  32. nHeight: c_int,
  33. hWndParent: HWND,
  34. hMenu: HMENU,
  35. hInstance: HINSTANCE,
  36. lpParam: LPVOID,
  37. ) -> HWND ---
  38. CreateWindowExW :: proc(
  39. dwExStyle: DWORD,
  40. lpClassName: LPCWSTR,
  41. lpWindowName: LPCWSTR,
  42. dwStyle: DWORD,
  43. X: c_int,
  44. Y: c_int,
  45. nWidth: c_int,
  46. nHeight: c_int,
  47. hWndParent: HWND,
  48. hMenu: HMENU,
  49. hInstance: HINSTANCE,
  50. lpParam: LPVOID,
  51. ) -> HWND ---
  52. DestroyWindow :: proc(hWnd: HWND) -> BOOL ---
  53. ShowWindow :: proc(hWnd: HWND, nCmdShow: c_int) -> BOOL ---
  54. BringWindowToTop :: proc(hWnd: HWND) -> BOOL ---
  55. GetTopWindow :: proc(hWnd: HWND) -> HWND ---
  56. SetForegroundWindow :: proc(hWnd: HWND) -> BOOL ---
  57. GetForegroundWindow :: proc() -> HWND ---
  58. SetActiveWindow :: proc(hWnd: HWND) -> HWND ---
  59. GetActiveWindow :: proc() -> HWND ---
  60. GetMessageA :: proc(lpMsg: ^MSG, hWnd: HWND, wMsgFilterMin: UINT, wMsgFilterMax: UINT) -> BOOL ---
  61. GetMessageW :: proc(lpMsg: ^MSG, hWnd: HWND, wMsgFilterMin: UINT, wMsgFilterMax: UINT) -> BOOL ---
  62. TranslateMessage :: proc(lpMsg: ^MSG) -> BOOL ---
  63. DispatchMessageA :: proc(lpMsg: ^MSG) -> LRESULT ---
  64. DispatchMessageW :: proc(lpMsg: ^MSG) -> LRESULT ---
  65. PeekMessageA :: proc(lpMsg: ^MSG, hWnd: HWND, wMsgFilterMin: UINT, wMsgFilterMax: UINT, wRemoveMsg: UINT) -> BOOL ---
  66. PeekMessageW :: proc(lpMsg: ^MSG, hWnd: HWND, wMsgFilterMin: UINT, wMsgFilterMax: UINT, wRemoveMsg: UINT) -> BOOL ---
  67. PostMessageA :: proc(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> BOOL ---
  68. PostMessageW :: proc(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> BOOL ---
  69. SendMessageA :: proc(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> LRESULT ---
  70. SendMessageW :: proc(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> LRESULT ---
  71. PostThreadMessageA :: proc(idThread: DWORD, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> BOOL ---
  72. PostThreadMessageW :: proc(idThread: DWORD, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> BOOL ---
  73. PostQuitMessage :: proc(nExitCode: c_int) ---
  74. GetQueueStatus :: proc(flags: UINT) -> DWORD ---
  75. DefWindowProcA :: proc(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> LRESULT ---
  76. DefWindowProcW :: proc(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> LRESULT ---
  77. FindWindowA :: proc(lpClassName: LPCSTR, lpWindowName: LPCSTR) -> HWND ---
  78. FindWindowW :: proc(lpClassName: LPCWSTR, lpWindowName: LPCWSTR) -> HWND ---
  79. FindWindowExA :: proc(hWndParent: HWND, hWndChildAfter: HWND, lpszClass: LPCSTR, lpszWindow: LPCSTR) -> HWND ---
  80. FindWindowExW :: proc(hWndParent: HWND, hWndChildAfter: HWND, lpszClass: LPCWSTR, lpszWindow: LPCWSTR) -> HWND ---
  81. LoadIconA :: proc(hInstance: HINSTANCE, lpIconName: LPCSTR) -> HICON ---
  82. LoadIconW :: proc(hInstance: HINSTANCE, lpIconName: LPCWSTR) -> HICON ---
  83. LoadCursorA :: proc(hInstance: HINSTANCE, lpCursorName: LPCSTR) -> HCURSOR ---
  84. LoadCursorW :: proc(hInstance: HINSTANCE, lpCursorName: LPCWSTR) -> HCURSOR ---
  85. GetWindowRect :: proc(hWnd: HWND, lpRect: LPRECT) -> BOOL ---
  86. GetClientRect :: proc(hWnd: HWND, lpRect: LPRECT) -> BOOL ---
  87. ClientToScreen :: 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. GetSystemMetrics :: proc(nIndex: c_int) -> c_int ---
  98. AdjustWindowRect :: proc(lpRect: LPRECT, dwStyle: DWORD, bMenu: BOOL) -> BOOL ---
  99. AdjustWindowRectEx :: proc(lpRect: LPRECT, dwStyle: DWORD, bMenu: BOOL, dwExStyle: DWORD) -> BOOL ---
  100. GetWindowDC :: proc(hWnd: HWND) -> HDC ---
  101. GetDC :: proc(hWnd: HWND) -> HDC ---
  102. ReleaseDC :: proc(hWnd: HWND, hDC: HDC) -> c_int ---
  103. GetUpdateRect :: proc(hWnd: HWND, lpRect: LPRECT, bErase: BOOL) -> BOOL ---
  104. ValidateRect :: proc(hWnd: HWND, lpRect: ^RECT) -> BOOL ---
  105. InvalidateRect :: proc(hWnd: HWND, lpRect: ^RECT, bErase: BOOL) -> BOOL ---
  106. BeginPaint :: proc(hWnd: HWND, lpPaint: ^PAINTSTRUCT) -> HDC ---
  107. EndPaint :: proc(hWnd: HWND, lpPaint: ^PAINTSTRUCT) -> BOOL ---
  108. GetCapture :: proc() -> HWND ---
  109. SetCapture :: proc(hWnd: HWND) -> HWND ---
  110. ReleaseCapture :: proc() -> BOOL ---
  111. TrackMouseEvent :: proc(lpEventTrack: LPTRACKMOUSEEVENT) -> BOOL ---
  112. GetKeyState :: proc(nVirtKey: c_int) -> SHORT ---
  113. GetAsyncKeyState :: proc(vKey: c_int) -> SHORT ---
  114. MapVirtualKeyA :: proc(uCode: UINT, uMapType: UINT) -> UINT ---
  115. MapVirtualKeyW :: proc(uCode: UINT, uMapType: UINT) -> UINT ---
  116. SetWindowsHookExA :: proc(idHook: c_int, lpfn: HOOKPROC, hmod: HINSTANCE, dwThreadId: DWORD) -> HHOOK ---
  117. SetWindowsHookExW :: proc(idHook: c_int, lpfn: HOOKPROC, hmod: HINSTANCE, dwThreadId: DWORD) -> HHOOK ---
  118. UnhookWindowsHookEx :: proc(hhk: HHOOK) -> BOOL ---
  119. CallNextHookEx :: proc(hhk: HHOOK, nCode: c_int, wParam: WPARAM, lParam: LPARAM) -> LRESULT ---
  120. SetTimer :: proc(hWnd: HWND, nIDEvent: UINT_PTR, uElapse: UINT, lpTimerFunc: TIMERPROC) -> UINT_PTR ---
  121. KillTimer :: proc(hWnd: HWND, uIDEvent: UINT_PTR) -> BOOL ---
  122. MessageBoxA :: proc(hWnd: HWND, lpText: LPCSTR, lpCaption: LPCSTR, uType: UINT) -> c_int ---
  123. MessageBoxW :: proc(hWnd: HWND, lpText: LPCWSTR, lpCaption: LPCWSTR, uType: UINT) -> c_int ---
  124. MessageBoxExA :: proc(hWnd: HWND, lpText: LPCSTR, lpCaption: LPCSTR, uType: UINT, wLanguageId: WORD) -> c_int ---
  125. MessageBoxExW :: proc(hWnd: HWND, lpText: LPCWSTR, lpCaption: LPCWSTR, uType: UINT, wLanguageId: WORD) -> c_int ---
  126. }
  127. CreateWindowA :: #force_inline proc "stdcall" (
  128. lpClassName: LPCSTR,
  129. lpWindowName: LPCSTR,
  130. dwStyle: DWORD,
  131. X: c_int,
  132. Y: c_int,
  133. nWidth: c_int,
  134. nHeight: c_int,
  135. hWndParent: HWND,
  136. hMenu: HMENU,
  137. hInstance: HINSTANCE,
  138. lpParam: LPVOID,
  139. ) -> HWND {
  140. return CreateWindowExA(
  141. 0,
  142. lpClassName,
  143. lpWindowName,
  144. dwStyle,
  145. X,
  146. Y,
  147. nWidth,
  148. nHeight,
  149. hWndParent,
  150. hMenu,
  151. hInstance,
  152. lpParam,
  153. )
  154. }
  155. CreateWindowW :: #force_inline proc "stdcall" (
  156. lpClassName: LPCTSTR,
  157. lpWindowName: LPCTSTR,
  158. dwStyle: DWORD,
  159. X: c_int,
  160. Y: c_int,
  161. nWidth: c_int,
  162. nHeight: c_int,
  163. hWndParent: HWND,
  164. hMenu: HMENU,
  165. hInstance: HINSTANCE,
  166. lpParam: LPVOID,
  167. ) -> HWND {
  168. return CreateWindowExW(
  169. 0,
  170. lpClassName,
  171. lpWindowName,
  172. dwStyle,
  173. X,
  174. Y,
  175. nWidth,
  176. nHeight,
  177. hWndParent,
  178. hMenu,
  179. hInstance,
  180. lpParam,
  181. )
  182. }
  183. when ODIN_ARCH == .amd64 {
  184. @(default_calling_convention="stdcall")
  185. foreign user32 {
  186. GetClassLongPtrA :: proc(hWnd: HWND, nIndex: c_int) -> ULONG_PTR ---
  187. GetClassLongPtrW :: proc(hWnd: HWND, nIndex: c_int) -> ULONG_PTR ---
  188. SetClassLongPtrA :: proc(hWnd: HWND, nIndex: c_int, dwNewLong: LONG_PTR) -> ULONG_PTR ---
  189. SetClassLongPtrW :: proc(hWnd: HWND, nIndex: c_int, dwNewLong: LONG_PTR) -> ULONG_PTR ---
  190. GetWindowLongPtrA :: proc(hWnd: HWND, nIndex: c_int) -> LONG_PTR ---
  191. GetWindowLongPtrW :: proc(hWnd: HWND, nIndex: c_int) -> LONG_PTR ---
  192. SetWindowLongPtrA :: proc(hWnd: HWND, nIndex: c_int, dwNewLong: LONG_PTR) -> LONG_PTR ---
  193. SetWindowLongPtrW :: proc(hWnd: HWND, nIndex: c_int, dwNewLong: LONG_PTR) -> LONG_PTR ---
  194. }
  195. } else when ODIN_ARCH == .i386 {
  196. GetClassLongPtrA :: GetClassLongA
  197. GetClassLongPtrW :: GetClassLongW
  198. SetClassLongPtrA :: SetClassLongA
  199. SetClassLongPtrW :: SetClassLongW
  200. GetWindowLongPtrA :: GetWindowLongA
  201. GetWindowLongPtrW :: GetWindowLongW
  202. SetWindowLongPtrA :: GetWindowLongA
  203. SetWindowLongPtrW :: GetWindowLongW
  204. }
  205. GET_SC_WPARAM :: #force_inline proc "contextless" (wParam: WPARAM) -> c_int {
  206. return c_int(wParam) & 0xFFF0
  207. }
  208. GET_WHEEL_DELTA_WPARAM :: #force_inline proc "contextless" (wParam: WPARAM) -> c_short {
  209. return cast(c_short)HIWORD(cast(DWORD)wParam)
  210. }
  211. GET_KEYSTATE_WPARAM :: #force_inline proc "contextless" (wParam: WPARAM) -> WORD {
  212. return LOWORD(cast(DWORD)wParam)
  213. }
  214. GET_NCHITTEST_WPARAM :: #force_inline proc "contextless" (wParam: WPARAM) -> c_short {
  215. return cast(c_short)LOWORD(cast(DWORD)wParam)
  216. }
  217. GET_XBUTTON_WPARAM :: #force_inline proc "contextless" (wParam: WPARAM) -> WORD {
  218. return HIWORD(cast(DWORD)wParam)
  219. }