From 17d6ec8c4aaf2552037cc97e0c66cbe37f9a302d Mon Sep 17 00:00:00 2001 From: cxl Date: Fri, 27 May 2016 13:39:54 +0000 Subject: [PATCH] Core: Win32 DHCtrl accelerator support git-svn-id: svn://ultimatepp.org/upp/trunk@9887 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/CtrlCore/DHCtrl.cpp | 29 +++++++++++++++++++++++++++++ uppsrc/CtrlCore/Win32Ctrl.h | 1 + uppsrc/CtrlCore/Win32GuiA.h | 9 +++++++++ uppsrc/CtrlCore/Win32Wnd.cpp | 13 ++++++++++--- 4 files changed, 49 insertions(+), 3 deletions(-) diff --git a/uppsrc/CtrlCore/DHCtrl.cpp b/uppsrc/CtrlCore/DHCtrl.cpp index 34aec2157..8596f210e 100644 --- a/uppsrc/CtrlCore/DHCtrl.cpp +++ b/uppsrc/CtrlCore/DHCtrl.cpp @@ -6,14 +6,41 @@ NAMESPACE_UPP #ifndef PLATFORM_WINCE +Vector DHCtrl::all_active; + +void DHCtrl::RemoveActive() +{ + for(;;) { + int q = FindIndex(all_active, this); + if(q < 0) + return; + all_active.Remove(q); + } +} + +bool DHCtrl::PreprocessMessageAll(MSG& msg) +{ + for(auto q : all_active) + if(q->PreprocessMessage(msg)) + return true; + return false; +} + +bool DHCtrl::PreprocessMessage(MSG& msg) +{ + return false; +} + void DHCtrl::NcCreate(HWND _hwnd) { hwnd = _hwnd; + all_active.Add(this); } void DHCtrl::NcDestroy() { hwnd = NULL; + RemoveActive(); } LRESULT DHCtrl::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) @@ -28,6 +55,7 @@ void DHCtrl::CloseHWND() if(hwnd) { DestroyWindow(hwnd); hwnd = NULL; + RemoveActive(); } } @@ -80,6 +108,7 @@ DHCtrl::~DHCtrl() { CloseHWND(); BackPaint(EXCLUDEPAINT); + RemoveActive(); } #endif diff --git a/uppsrc/CtrlCore/Win32Ctrl.h b/uppsrc/CtrlCore/Win32Ctrl.h index 5cc75dc62..0259eeb6d 100644 --- a/uppsrc/CtrlCore/Win32Ctrl.h +++ b/uppsrc/CtrlCore/Win32Ctrl.h @@ -57,6 +57,7 @@ public: virtual void NcDestroy(); virtual void PreDestroy(); virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); + virtual bool PreprocessMessage(MSG& msg); HWND GetHWND() const { return parent ? NULL : top ? top->hwnd : NULL; } HWND GetOwnerHWND() const; diff --git a/uppsrc/CtrlCore/Win32GuiA.h b/uppsrc/CtrlCore/Win32GuiA.h index 3e1672ea9..7d8b2bfd0 100644 --- a/uppsrc/CtrlCore/Win32GuiA.h +++ b/uppsrc/CtrlCore/Win32GuiA.h @@ -79,11 +79,20 @@ public: virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); virtual void NcCreate(HWND hwnd); virtual void NcDestroy(); + virtual bool PreprocessMessage(MSG& msg); private: void OpenHWND(); void SyncHWND(); + void RemoveActive(); + + static Vector all_active; + + static bool PreprocessMessageAll(MSG& msg); + + friend class Ctrl; + protected: void CloseHWND(); HWND hwnd; diff --git a/uppsrc/CtrlCore/Win32Wnd.cpp b/uppsrc/CtrlCore/Win32Wnd.cpp index 3c5209fe1..234f60531 100644 --- a/uppsrc/CtrlCore/Win32Wnd.cpp +++ b/uppsrc/CtrlCore/Win32Wnd.cpp @@ -611,6 +611,11 @@ void Ctrl::NcDestroy() WndFree(); } +bool Ctrl::PreprocessMessage(MSG& msg) +{ + return false; +} + LRESULT CALLBACK Ctrl::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { GuiLock __; @@ -747,9 +752,11 @@ void Ctrl::sProcessMSG(MSG& msg) Ctrl::hotkey[(int)msg.wParam](); return; } - if(msg.message != WM_SYSKEYDOWN && msg.message != WM_SYSKEYUP - || PassWindowsKey((dword)msg.wParam) || msg.wParam == VK_MENU) //17.11 Mirek - fix to get windows menu invoked on Alt+Space - TranslateMessage(&msg); // 04/09/07: TRC fix to make barcode reader going better + + if(!DHCtrl::PreprocessMessageAll(msg)) + if(msg.message != WM_SYSKEYDOWN && msg.message != WM_SYSKEYUP + || PassWindowsKey((dword)msg.wParam) || msg.wParam == VK_MENU) //17.11 Mirek - fix to get windows menu invoked on Alt+Space + TranslateMessage(&msg); // 04/09/07: TRC fix to make barcode reader going better #if 0 DDUMP(msg.hwnd);