diff options
| author | Pietro Gagliardi <[email protected]> | 2015-12-11 20:37:59 -0500 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2015-12-11 20:37:59 -0500 |
| commit | f8e3f12ab02b528f2a05a4f713d7af7ea8e44b42 (patch) | |
| tree | 82dedf4d37f0f6d31e88ebb2ca1ce6499dead261 /common_windows.go | |
| parent | e34c561ed5bedeb180437ec165882b98d70d38c1 (diff) | |
LET'S GET THIS FINAL REWRITE EVER STARTED
Diffstat (limited to 'common_windows.go')
| -rw-r--r-- | common_windows.go | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/common_windows.go b/common_windows.go deleted file mode 100644 index 7a12a8a..0000000 --- a/common_windows.go +++ /dev/null @@ -1,58 +0,0 @@ -// 12 july 2014 - -package ui - -import ( - "fmt" - "reflect" - "syscall" - "unsafe" -) - -// #include "winapi_windows.h" -import "C" - -//export xpanic -func xpanic(msg *C.char, lasterr C.DWORD) { - panic(fmt.Errorf("%s: %s", C.GoString(msg), syscall.Errno(lasterr))) -} - -//export xpanichresult -func xpanichresult(msg *C.char, hresult C.HRESULT) { - panic(fmt.Errorf("%s; HRESULT: 0x%X", C.GoString(msg), hresult)) -} - -//export xpaniccomdlg -func xpaniccomdlg(msg *C.char, err C.DWORD) { - panic(fmt.Errorf("%s; comdlg32.dll extended error: 0x%X", C.GoString(msg), err)) -} - -//export xmissedmsg -func xmissedmsg(purpose *C.char, f *C.char, uMsg C.UINT) { - panic(fmt.Errorf("%s window procedure message %d does not return a value (bug in %s)", C.GoString(purpose), uMsg, C.GoString(f))) -} - -func toUTF16(s string) C.LPWSTR { - return C.LPWSTR(unsafe.Pointer(syscall.StringToUTF16Ptr(s))) -} - -func getWindowText(hwnd C.HWND) string { - // WM_GETTEXTLENGTH and WM_GETTEXT return the count /without/ the terminating null character - // but WM_GETTEXT expects the buffer size handed to it to /include/ the terminating null character - n := C.getWindowTextLen(hwnd) - buf := make([]uint16, int(n+1)) - C.getWindowText(hwnd, C.WPARAM(n), - C.LPWSTR(unsafe.Pointer(&buf[0]))) - return syscall.UTF16ToString(buf) -} - -func wstrToString(wstr *C.WCHAR) string { - n := C.wcslen((*C.wchar_t)(unsafe.Pointer(wstr))) - xbuf := &reflect.SliceHeader{ - Data: uintptr(unsafe.Pointer(wstr)), - Len: int(n + 1), - Cap: int(n + 1), - } - buf := (*[]uint16)(unsafe.Pointer(xbuf)) - return syscall.UTF16ToString(*buf) -} |
