diff options
| author | Pietro Gagliardi <[email protected]> | 2014-07-17 23:14:22 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-07-17 23:14:22 -0400 |
| commit | d8f302f15728ab6222310657e508cf4480080c79 (patch) | |
| tree | de78f85b7a53f752197603f8401fe2f5f5c60640 | |
| parent | 0dc1538002b22064457f6fe778dab15b81944882 (diff) | |
Some Unicode-related fixups and additions in the new Windows code.
| -rw-r--r-- | redo/common_windows.go | 4 | ||||
| -rw-r--r-- | redo/uitask_windows.c | 16 |
2 files changed, 12 insertions, 8 deletions
diff --git a/redo/common_windows.go b/redo/common_windows.go index b1fa0ee..b34a623 100644 --- a/redo/common_windows.go +++ b/redo/common_windows.go @@ -21,6 +21,10 @@ 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 toUINT16(s string) C.LPCWSTR { + return C.LPCWSTR(unsafe.Pointer(syscall.StringToUTF16(s))) +} + func getWindowText(hwnd uintptr) 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 diff --git a/redo/uitask_windows.c b/redo/uitask_windows.c index 9177e19..11ce412 100644 --- a/redo/uitask_windows.c +++ b/redo/uitask_windows.c @@ -10,21 +10,21 @@ void uimsgloop(void) for (;;) { SetLastError(0); - res = GetMessage(&msg, NULL, 0, 0); + res = GetMessageW(&msg, NULL, 0, 0); if (res < 0) xpanic("error calling GetMessage()", GetLastError()); if (res == 0) /* WM_QUIT */ break; /* TODO IsDialogMessage() */ TranslateMessage(&msg); - DispatchMessage(&msg); + DispatchMessageW(&msg); } } void issue(void *request) { SetLastError(0); - if (PostMessage(msgwin, msgRequested, 0, (LPARAM) request) == 0) + if (PostMessageW(msgwin, msgRequested, 0, (LPARAM) request) == 0) xpanic("error issuing request", GetLastError()); } @@ -41,7 +41,7 @@ static LRESULT CALLBACK msgwinproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l xperform((void *) lParam); return 0; default: - return DefWindowProc(hwnd, uMsg, wParam, lParam); + return DefWindowProcW(hwnd, uMsg, wParam, lParam); } xmissedmsg("message-only", "msgwinproc()", uMsg); return 0; /* unreachable */ @@ -49,21 +49,21 @@ static LRESULT CALLBACK msgwinproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l DWORD makemsgwin(char **errmsg) { - WNDCLASS wc; + WNDCLASSW wc; HWND hwnd; - ZeroMemory(&wc, sizeof (WNDCLASS)); + ZeroMemory(&wc, sizeof (WNDCLASSW)); wc.lpfnWndProc = msgwinproc; wc.hInstance = hInstance; wc.hIcon = hDefaultIcon; wc.hCursor = hArrowCursor; wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1); wc.lpszClassName = msgwinclass; - if (RegisterClass(&wc) == 0) { + if (RegisterClassW(&wc) == 0) { *errmsg = "error registering message-only window classs"; return GetLastError(); } - msgwin = CreateWindowEx( + msgwin = CreateWindowExW( 0, msgwinclass, L"package ui message-only window", 0, |
