From 719cab87420d29a57223b356556c55ce40cfe46d Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 13 Apr 2014 13:11:17 -0400 Subject: [PATCH] Migrated cursors_windows.go and icons_windows.go. --- common_windows.go | 34 ++++++++++++++++++++++++++++ stdwndclass_windows.go | 9 ++------ unmigrated/cursors_windows.go | 42 ----------------------------------- unmigrated/icons_windows.go | 36 ------------------------------ 4 files changed, 36 insertions(+), 85 deletions(-) delete mode 100644 unmigrated/cursors_windows.go delete mode 100644 unmigrated/icons_windows.go diff --git a/common_windows.go b/common_windows.go index e02a976..fb78ed7 100644 --- a/common_windows.go +++ b/common_windows.go @@ -75,3 +75,37 @@ type _RECT struct { Right int32 Bottom int32 } + +// Predefined cursor resource IDs. +const ( + _IDC_APPSTARTING = 32650 + _IDC_ARROW = 32512 + _IDC_CROSS = 32515 + _IDC_HAND = 32649 + _IDC_HELP = 32651 + _IDC_IBEAM = 32513 +// _IDC_ICON = 32641 // [Obsolete for applications marked version 4.0 or later.] + _IDC_NO = 32648 +// _IDC_SIZE = 32640 // [Obsolete for applications marked version 4.0 or later. Use IDC_SIZEALL.] + _IDC_SIZEALL = 32646 + _IDC_SIZENESW = 32643 + _IDC_SIZENS = 32645 + _IDC_SIZENWSE = 32642 + _IDC_SIZEWE = 32644 + _IDC_UPARROW = 32516 + _IDC_WAIT = 32514 +) + +// Predefined icon resource IDs. +const ( + _IDI_APPLICATION = 32512 + _IDI_ASTERISK = 32516 + _IDI_ERROR = 32513 + _IDI_EXCLAMATION = 32515 + _IDI_HAND = 32513 + _IDI_INFORMATION = 32516 + _IDI_QUESTION = 32514 + _IDI_SHIELD = 32518 + _IDI_WARNING = 32515 + _IDI_WINLOGO = 32517 +) diff --git a/stdwndclass_windows.go b/stdwndclass_windows.go index e3368ca..edf0149 100644 --- a/stdwndclass_windows.go +++ b/stdwndclass_windows.go @@ -123,14 +123,9 @@ func registerStdWndClass(s *sysData) (newClassName string, err error) { } func initWndClassInfo() (err error) { - const ( - _IDI_APPLICATION = 32512 - _IDC_ARROW = 32512 - ) - r1, _, err := user32.NewProc("LoadIconW").Call( uintptr(_NULL), - uintptr(_IDI_APPLICATION)) + _MAKEINTRESOURCE(_IDI_APPLICATION)) if r1 == 0 { // failure return fmt.Errorf("error getting window icon: %v", err) } @@ -138,7 +133,7 @@ func initWndClassInfo() (err error) { r1, _, err = user32.NewProc("LoadCursorW").Call( uintptr(_NULL), - uintptr(_IDC_ARROW)) + _MAKEINTRESOURCE(_IDC_ARROW)) if r1 == 0 { // failure return fmt.Errorf("error getting window cursor: %v", err) } diff --git a/unmigrated/cursors_windows.go b/unmigrated/cursors_windows.go deleted file mode 100644 index a275ebe..0000000 --- a/unmigrated/cursors_windows.go +++ /dev/null @@ -1,42 +0,0 @@ -// 8 february 2014 - -package ui - -import ( -// "syscall" -// "unsafe" -) - -// Predefined cursor resource IDs. -const ( - IDC_APPSTARTING = 32650 - IDC_ARROW = 32512 - IDC_CROSS = 32515 - IDC_HAND = 32649 - IDC_HELP = 32651 - IDC_IBEAM = 32513 -// IDC_ICON = 32641 // [Obsolete for applications marked version 4.0 or later.] - IDC_NO = 32648 -// IDC_SIZE = 32640 // [Obsolete for applications marked version 4.0 or later. Use IDC_SIZEALL.] - IDC_SIZEALL = 32646 - IDC_SIZENESW = 32643 - IDC_SIZENS = 32645 - IDC_SIZENWSE = 32642 - IDC_SIZEWE = 32644 - IDC_UPARROW = 32516 - IDC_WAIT = 32514 -) - -var ( - loadCursor = user32.NewProc("LoadCursorW") -) - -func LoadCursor_ResourceID(hInstance HANDLE, lpCursorName uint16) (cursor HANDLE, err error) { - r1, _, err := loadCursor.Call( - uintptr(hInstance), - MAKEINTRESOURCE(lpCursorName)) - if r1 == 0 { // failure - return NULL, err - } - return HANDLE(r1), nil -} diff --git a/unmigrated/icons_windows.go b/unmigrated/icons_windows.go deleted file mode 100644 index 85ccad1..0000000 --- a/unmigrated/icons_windows.go +++ /dev/null @@ -1,36 +0,0 @@ -// 8 february 2014 - -package ui - -import ( -// "syscall" -// "unsafe" -) - -// Predefined icon resource IDs. -const ( - IDI_APPLICATION = 32512 - IDI_ASTERISK = 32516 - IDI_ERROR = 32513 - IDI_EXCLAMATION = 32515 - IDI_HAND = 32513 - IDI_INFORMATION = 32516 - IDI_QUESTION = 32514 - IDI_SHIELD = 32518 - IDI_WARNING = 32515 - IDI_WINLOGO = 32517 -) - -var ( - loadIcon = user32.NewProc("LoadIconW") -) - -func LoadIcon_ResourceID(hInstance HANDLE, lpIconName uint16) (icon HANDLE, err error) { - r1, _, err := loadIcon.Call( - uintptr(hInstance), - MAKEINTRESOURCE(lpIconName)) - if r1 == 0 { // failure - return NULL, err - } - return HANDLE(r1), nil -}