From f10c1f56b54ecd1b8fcd0d7486535a5d50e28957 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sat, 23 Aug 2014 19:44:55 -0400 Subject: [PATCH] More fixes to Windows Area.OpenTextFieldAt(). Thanks to http://stackoverflow.com/questions/25462989/why-am-i-getting-wm-mouseactivate-when-i-click-on-my-child-window-i-have-it-cha --- redo/area_windows.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/redo/area_windows.c b/redo/area_windows.c index 8985c04..58d8c56 100644 --- a/redo/area_windows.c +++ b/redo/area_windows.c @@ -340,36 +340,32 @@ static LRESULT CALLBACK areaWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM // don't keep the double-click timer running if the user switched programs in between clicks areaResetClickCounter(data); return 0; - case WM_MOUSEACTIVATE: - // this happens on every mouse click (apparently), so DON'T reset the click counter, otherwise it will always be reset (not an issue, as MSDN says WM_ACTIVATE is sent alongside WM_MOUSEACTIVATE when necessary) - // transfer keyboard focus to our Area on an activating click - // (see http://www.catch22.net/tuts/custom-controls) - // don't bother checking SetFocus()'s error; see http://stackoverflow.com/questions/24073695/winapi-can-setfocus-return-null-without-an-error-because-thats-what-im-see/24074912#24074912 - SetFocus(hwnd); - // and don't eat the click, as we want to handle clicks that switch into Windows with Areas from other windows - return MA_ACTIVATE; case WM_MOUSEMOVE: areaMouseEvent(hwnd, data, 0, FALSE, heldButtons, lParam); return 0; case WM_LBUTTONDOWN: + SetFocus(hwnd); areaMouseEvent(hwnd, data, 1, FALSE, heldButtons, lParam); return 0; case WM_LBUTTONUP: areaMouseEvent(hwnd, data, 1, TRUE, heldButtons, lParam); return 0; case WM_MBUTTONDOWN: + SetFocus(hwnd); // TODO correct? areaMouseEvent(hwnd, data, 2, FALSE, heldButtons, lParam); return 0; case WM_MBUTTONUP: areaMouseEvent(hwnd, data, 2, TRUE, heldButtons, lParam); return 0; case WM_RBUTTONDOWN: + SetFocus(hwnd); // TODO correct? areaMouseEvent(hwnd, data, 3, FALSE, heldButtons, lParam); return 0; case WM_RBUTTONUP: areaMouseEvent(hwnd, data, 3, TRUE, heldButtons, lParam); return 0; case WM_XBUTTONDOWN: + SetFocus(hwnd); // TODO correct? // values start at 1; we want them to start at 4 which = (DWORD) GET_XBUTTON_WPARAM(wParam) + 3; heldButtons = (uintptr_t) GET_KEYSTATE_WPARAM(wParam); @@ -460,9 +456,9 @@ HWND newAreaTextField(HWND area) { HWND tf; - tf = CreateWindowExW(textfieldExtStyle | WS_EX_TOOLWINDOW, + tf = CreateWindowExW(textfieldExtStyle, L"edit", L"", - textfieldStyle | WS_POPUP, + textfieldStyle | WS_CHILD, 0, 0, 0, 0, area, // owner window NULL, hInstance, NULL);