LRESULT NativeWindowHolder::WindowProcedure(UINT message, WPARAM wParam, LPARAM lParam) { return CallBaseWindowProcedure(message, wParam, lParam); }
LRESULT HotKeyInputWindow::WindowProcedure(UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_SETFOCUS: { hasFocus = true; RenderToBuffer(); ShowCustomCaret(); InvalidateRect(windowHandle, nullptr, TRUE); context->GetMessageBus()->SuspendHotkeys(); return TRUE; } case WM_KILLFOCUS: { hasFocus = false; RenderToBuffer(); AssertCriticalWinApiResult(HideCaret(windowHandle)); InvalidateRect(windowHandle, nullptr, TRUE); context->GetMessageBus()->EnableHotkeys(); return TRUE; } case WM_SETCURSOR: { SetCursor(LoadCursor(nullptr, IDC_IBEAM)); return TRUE; } case WM_PAINT: { PAINTSTRUCT ps; AssertCriticalWinApiResult(BeginPaint(GetHandle(), &ps)); Draw(false); EndPaint(GetHandle(), &ps); if (GetFocus() == windowHandle) { ShowCustomCaret(); } return TRUE; } case WM_KEYDOWN: case WM_KEYUP: { int procedureResult = CallBaseWindowProcedure(message, wParam, lParam); currentHotkey = SendMessage(windowHandle, HKM_GETHOTKEY, 0, 0); int virtualCode = LOBYTE(LOWORD(currentHotkey)); int modifier = HIBYTE(LOWORD(currentHotkey)); if(message == WM_KEYUP) { OnHotkeyChanged.Notify(currentHotkey); } else { bool isModifierInvalid = modifier == 0 || (modifier & HOTKEYF_EXT) == HOTKEYF_EXT; bool isKeyInvalid = virtualCode != 0 && MapVirtualKey(virtualCode, MAPVK_VK_TO_CHAR) == 0; if (isModifierInvalid || isKeyInvalid) { currentHotkey = 0; SendMessage(windowHandle, HKM_SETHOTKEY, 0, 0); } } RenderToBuffer(); return procedureResult; } } return ChildWindow::WindowProcedure(message, wParam, lParam); }