From 1d8bc3e917b3cf5713e56a0f07b0a8a811d09d2b Mon Sep 17 00:00:00 2001 From: hikari Date: Thu, 24 Mar 2022 17:32:11 +0200 Subject: [PATCH 1/5] sys/windows: fix gdi32 raw pointer types --- core/sys/windows/gdi32.odin | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/sys/windows/gdi32.odin b/core/sys/windows/gdi32.odin index 2caf42753..15d5567c7 100644 --- a/core/sys/windows/gdi32.odin +++ b/core/sys/windows/gdi32.odin @@ -14,7 +14,7 @@ foreign gdi32 { hdc: HDC, pbmih: ^BITMAPINFOHEADER, flInit: DWORD, - pjBits: ^VOID, + pjBits: VOID, pbmi: ^BITMAPINFO, iUsage: UINT, ) -> HBITMAP --- @@ -23,7 +23,7 @@ foreign gdi32 { hdc: HDC, pbmi: ^BITMAPINFO, usage: UINT, - ppvBits: ^^VOID, + ppvBits: VOID, hSection: HANDLE, offset: DWORD, ) -> HBITMAP --- @@ -38,7 +38,7 @@ foreign gdi32 { ySrc: c_int, SrcWidth: c_int, SrcHeight: c_int, - lpBits: ^VOID, + lpBits: VOID, lpbmi: ^BITMAPINFO, iUsage: UINT, rop: DWORD, From 5d7b92d391bcddf98cc94b99f932e391cd3cbb40 Mon Sep 17 00:00:00 2001 From: hikari Date: Thu, 24 Mar 2022 18:40:23 +0200 Subject: [PATCH 2/5] sys/windows: add mouse states masks --- core/sys/windows/types.odin | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/sys/windows/types.odin b/core/sys/windows/types.odin index 9a4a1ab5e..63e66ee83 100644 --- a/core/sys/windows/types.odin +++ b/core/sys/windows/types.odin @@ -416,6 +416,15 @@ WMSZ_BOTTOM :: 6 WMSZ_BOTTOMLEFT :: 7 WMSZ_BOTTOMRIGHT :: 8 +// Key State Masks for Mouse Messages +MK_LBUTTON :: 0x0001 +MK_RBUTTON :: 0x0002 +MK_SHIFT :: 0x0004 +MK_CONTROL :: 0x0008 +MK_MBUTTON :: 0x0010 +MK_XBUTTON1 :: 0x0020 +MK_XBUTTON2 :: 0x0040 + _IDC_APPSTARTING := rawptr(uintptr(32650)) _IDC_ARROW := rawptr(uintptr(32512)) _IDC_CROSS := rawptr(uintptr(32515)) From 2f9a410a45bc6f8c0610417e8406793989177a7a Mon Sep 17 00:00:00 2001 From: hikari Date: Fri, 25 Mar 2022 16:09:16 +0200 Subject: [PATCH 3/5] sys/windows: add SetWindowPos() --- core/sys/windows/types.odin | 33 +++++++++++++++++++++++++++++++++ core/sys/windows/user32.odin | 9 +++++++++ 2 files changed, 42 insertions(+) diff --git a/core/sys/windows/types.odin b/core/sys/windows/types.odin index 63e66ee83..0c6327cc2 100644 --- a/core/sys/windows/types.odin +++ b/core/sys/windows/types.odin @@ -399,6 +399,30 @@ SW_RESTORE : c_int : 9 SW_SHOWDEFAULT : c_int : 10 SW_FORCEMINIMIZE : c_int : 11 +// SetWindowPos Flags +SWP_NOSIZE :: 0x0001 +SWP_NOMOVE :: 0x0002 +SWP_NOZORDER :: 0x0004 +SWP_NOREDRAW :: 0x0008 +SWP_NOACTIVATE :: 0x0010 +SWP_FRAMECHANGED :: 0x0020 // The frame changed: send WM_NCCALCSIZE +SWP_SHOWWINDOW :: 0x0040 +SWP_HIDEWINDOW :: 0x0080 +SWP_NOCOPYBITS :: 0x0100 +SWP_NOOWNERZORDER :: 0x0200 // Don't do owner Z ordering +SWP_NOSENDCHANGING :: 0x0400 // Don't send WM_WINDOWPOSCHANGING + +SWP_DRAWFRAME :: SWP_FRAMECHANGED +SWP_NOREPOSITION :: SWP_NOOWNERZORDER + +SWP_DEFERERASE :: 0x2000 // same as SWP_DEFERDRAWING +SWP_ASYNCWINDOWPOS :: 0x4000 // same as SWP_CREATESPB + +HWND_TOP : HWND : 0 +HWND_BOTTOM : HWND : 1 +HWND_TOPMOST : HWND : -1 +HWND_NOTOPMOST : HWND : -2 + CW_USEDEFAULT : c_int : -2147483648 SIZE_RESTORED :: 0 @@ -846,6 +870,15 @@ FILE_TYPE_PIPE :: 0x0003 RECT :: struct {left, top, right, bottom: LONG} POINT :: struct {x, y: LONG} +WINDOWPOS :: struct { + hwnd: HWND, + hwndInsertAfter: HWND, + x: c_int, + y: c_int, + cx: c_int, + cy: c_int, + flags: UINT, +} when size_of(uintptr) == 4 { WSADATA :: struct { diff --git a/core/sys/windows/user32.odin b/core/sys/windows/user32.odin index fc001f26b..6e57196ee 100644 --- a/core/sys/windows/user32.odin +++ b/core/sys/windows/user32.odin @@ -97,6 +97,15 @@ foreign user32 { LoadCursorW :: proc(hInstance: HINSTANCE, lpCursorName: LPCWSTR) -> HCURSOR --- GetClientRect :: proc(hWnd: HWND, lpRect: ^RECT) -> BOOL --- + SetWindowPos :: proc( + hWnd: HWND, + hWndInsertAfter: HWND, + X: c_int, + Y: c_int, + cx: c_int, + cy: c_int, + uFlags: UINT, + ) -> BOOL --- GetWindowDC :: proc(hWnd: HWND) -> HDC --- GetDC :: proc(hWnd: HWND) -> HDC --- From f8d3f86d8b79cc0ee811490455452423fae0fc88 Mon Sep 17 00:00:00 2001 From: hikari Date: Fri, 25 Mar 2022 16:17:53 +0200 Subject: [PATCH 4/5] sys/windows: fix build --- core/sys/windows/types.odin | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/sys/windows/types.odin b/core/sys/windows/types.odin index 0c6327cc2..5e1aa2503 100644 --- a/core/sys/windows/types.odin +++ b/core/sys/windows/types.odin @@ -418,10 +418,10 @@ SWP_NOREPOSITION :: SWP_NOOWNERZORDER SWP_DEFERERASE :: 0x2000 // same as SWP_DEFERDRAWING SWP_ASYNCWINDOWPOS :: 0x4000 // same as SWP_CREATESPB -HWND_TOP : HWND : 0 -HWND_BOTTOM : HWND : 1 -HWND_TOPMOST : HWND : -1 -HWND_NOTOPMOST : HWND : -2 +HWND_TOP :: 0 +HWND_BOTTOM :: 1 +HWND_TOPMOST :: -1 +HWND_NOTOPMOST :: -2 CW_USEDEFAULT : c_int : -2147483648 From 73b81184fa3c7f97b5b945a0d459cb09bd91aa97 Mon Sep 17 00:00:00 2001 From: hikari Date: Fri, 25 Mar 2022 20:53:17 +0200 Subject: [PATCH 5/5] sys/windows: add MessageBox procedures --- core/sys/windows/types.odin | 59 ++++++++++++++++++++++++++++++++++++ core/sys/windows/user32.odin | 5 +++ 2 files changed, 64 insertions(+) diff --git a/core/sys/windows/types.odin b/core/sys/windows/types.odin index 5e1aa2503..bd6eba24e 100644 --- a/core/sys/windows/types.odin +++ b/core/sys/windows/types.odin @@ -312,6 +312,65 @@ CREATESTRUCTW:: struct { dwExStyle: DWORD, } +// MessageBox() Flags +MB_OK :: 0x00000000 +MB_OKCANCEL :: 0x00000001 +MB_ABORTRETRYIGNORE :: 0x00000002 +MB_YESNOCANCEL :: 0x00000003 +MB_YESNO :: 0x00000004 +MB_RETRYCANCEL :: 0x00000005 +MB_CANCELTRYCONTINUE :: 0x00000006 + +MB_ICONHAND :: 0x00000010 +MB_ICONQUESTION :: 0x00000020 +MB_ICONEXCLAMATION :: 0x00000030 +MB_ICONASTERISK :: 0x00000040 +MB_USERICON :: 0x00000080 +MB_ICONWARNING :: MB_ICONEXCLAMATION +MB_ICONERROR :: MB_ICONHAND +MB_ICONINFORMATION :: MB_ICONASTERISK +MB_ICONSTOP :: MB_ICONHAND + +MB_DEFBUTTON1 :: 0x00000000 +MB_DEFBUTTON2 :: 0x00000100 +MB_DEFBUTTON3 :: 0x00000200 +MB_DEFBUTTON4 :: 0x00000300 + +MB_APPLMODAL :: 0x00000000 +MB_SYSTEMMODAL :: 0x00001000 +MB_TASKMODAL :: 0x00002000 +MB_HELP :: 0x00004000 // Help Button + +MB_NOFOCUS :: 0x00008000 +MB_SETFOREGROUND :: 0x00010000 +MB_DEFAULT_DESKTOP_ONLY :: 0x00020000 +MB_TOPMOST :: 0x00040000 +MB_RIGHT :: 0x00080000 +MB_RTLREADING :: 0x00100000 + +MB_SERVICE_NOTIFICATION :: 0x00200000 +MB_SERVICE_NOTIFICATION_NT3X :: 0x00040000 + +MB_TYPEMASK :: 0x0000000F +MB_ICONMASK :: 0x000000F0 +MB_DEFMASK :: 0x00000F00 +MB_MODEMASK :: 0x00003000 +MB_MISCMASK :: 0x0000C000 + +// Dialog Box Command IDs +IDOK :: 1 +IDCANCEL :: 2 +IDABORT :: 3 +IDRETRY :: 4 +IDIGNORE :: 5 +IDYES :: 6 +IDNO :: 7 +IDCLOSE :: 8 +IDHELP :: 9 +IDTRYAGAIN :: 10 +IDCONTINUE :: 11 +IDTIMEOUT :: 32000 + CS_VREDRAW : UINT : 0x0001 CS_HREDRAW : UINT : 0x0002 CS_DBLCLKS : UINT : 0x0008 diff --git a/core/sys/windows/user32.odin b/core/sys/windows/user32.odin index 6e57196ee..2336878ef 100644 --- a/core/sys/windows/user32.odin +++ b/core/sys/windows/user32.odin @@ -120,6 +120,11 @@ foreign user32 { GetKeyState :: proc(nVirtKey: c_int) -> SHORT --- GetAsyncKeyState :: proc(vKey: c_int) -> SHORT --- + + MessageBoxA :: proc(hWnd: HWND, lpText: LPCSTR, lpCaption: LPCSTR, uType: UINT) -> c_int --- + MessageBoxW :: proc(hWnd: HWND, lpText: LPCWSTR, lpCaption: LPCWSTR, uType: UINT) -> c_int --- + MessageBoxExA :: proc(hWnd: HWND, lpText: LPCSTR, lpCaption: LPCSTR, uType: UINT, wLanguageId: WORD) -> c_int --- + MessageBoxExW :: proc(hWnd: HWND, lpText: LPCWSTR, lpCaption: LPCWSTR, uType: UINT, wLanguageId: WORD) -> c_int --- } CreateWindowA :: #force_inline proc "stdcall" (