diff options
| author | Pietro Gagliardi <[email protected]> | 2014-02-11 13:06:12 -0500 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-02-11 13:06:12 -0500 |
| commit | 42229820d2a47594f68d92356f8e8a86133a29f5 (patch) | |
| tree | 3cd5deef283b4540bae2f75c049a5e69d4e9db20 /common.go | |
| parent | a488e3ab36de1d6a329110fbaae44cd5747c854b (diff) | |
Added _windows.go extensions to all the files in preparation for the library writing.
Diffstat (limited to 'common.go')
| -rw-r--r-- | common.go | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/common.go b/common.go deleted file mode 100644 index 79d6fc9..0000000 --- a/common.go +++ /dev/null @@ -1,73 +0,0 @@ -// 7 february 2014 -package main - -import ( - "syscall" - "unsafe" -) - -// TODO filter out commctrl.h stuff because the combobox and listbox stuff has values that differ between windows versions and bleh -// either that or switch to ComboBoxEx and ListView because they might not have that problem??? - -var ( - user32 = syscall.NewLazyDLL("user32.dll") - kernel32 = syscall.NewLazyDLL("kernel32.dll") - gdi32 = syscall.NewLazyDLL("gdi32.dll") -) - -type HANDLE uintptr -type HWND HANDLE -type HBRUSH HANDLE -type HMENU HANDLE - -const ( - NULL = 0 - FALSE = 0 // from windef.h - TRUE = 1 // from windef.h -) - -type ATOM uint16 - -// TODO pull the thanks for these three from the old wingo source -// TODO put these in windows.go -type WPARAM uintptr -type LPARAM uintptr -type LRESULT uintptr - -func (w WPARAM) LOWORD() uint16 { - // according to windef.h - return uint16(w & 0xFFFF) -} - -func (w WPARAM) HIWORD() uint16 { - // according to windef.h - return uint16((w >> 16) & 0xFFFF) -} - -func LPARAMFromString(str string) LPARAM { - return LPARAM(unsafe.Pointer(syscall.StringToUTF16Ptr(str))) -} - -// microsoft's header files do this -func MAKEINTRESOURCE(what uint16) uintptr { - return uintptr(what) -} - -// TODO adorn error messages with which step failed? -func getText(hwnd HWND) (text string, err error) { - var tc []uint16 - - length, err := SendMessage(hwnd, WM_GETTEXTLENGTH, 0, 0) - if err != nil { - return "", err - } - tc = make([]uint16, length + 1) - _, err = SendMessage(hwnd, - WM_GETTEXT, - WPARAM(length + 1), - LPARAM(unsafe.Pointer(&tc[0]))) - if err != nil { - return "", err - } - return syscall.UTF16ToString(tc), nil -} |
