From 540b6b097f0a8056189b3f9ab5aab5c99834b9c7 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 10 Jul 2003 09:56:47 +0000 Subject: [PATCH] linking fixes and code cleanup after hotkey patch git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21848 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/window.h | 6 +-- include/wx/window.h | 11 +++-- src/common/wincmn.cpp | 11 +++-- src/msw/window.cpp | 93 ++++++++++++++++++++++------------------- 4 files changed, 69 insertions(+), 52 deletions(-) diff --git a/include/wx/msw/window.h b/include/wx/msw/window.h index 0e0f8317df..63cdaf66dd 100644 --- a/include/wx/msw/window.h +++ b/include/wx/msw/window.h @@ -177,11 +177,11 @@ public: wxWindow* GetWindowChild(wxWindowID id); #endif // __WXUNIVERSAL__ -#if wxUSE_ACCEL +#if wxUSE_HOTKEY // install and deinstall a system wide hotkey - virtual bool RegisterHotKey(int hotkeyId, int modifiers, int virtualKeyCode); + virtual bool RegisterHotKey(int hotkeyId, int modifiers, int keycode); virtual bool UnregisterHotKey(int hotkeyId); -#endif +#endif // wxUSE_HOTKEY // implementation from now on // -------------------------- diff --git a/include/wx/window.h b/include/wx/window.h index 959f775c70..877456d967 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -517,11 +517,16 @@ public: wxAcceleratorTable *GetAcceleratorTable() { return &m_acceleratorTable; } - // install and deinstall a system wide hotkey - virtual bool RegisterHotKey(int hotkeyId, int modifiers, int virtualKeyCode); +#endif // wxUSE_ACCEL + +#if wxUSE_HOTKEY + // hot keys (system wide accelerators) + // ----------------------------------- + + virtual bool RegisterHotKey(int hotkeyId, int modifiers, int keycode); virtual bool UnregisterHotKey(int hotkeyId); +#endif // wxUSE_HOTKEY -#endif // wxUSE_ACCEL // dialog units translations // ------------------------- diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index 06582f8f98..61402fabf0 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -2107,18 +2107,23 @@ void wxWindowBase::ReleaseMouse() } #if wxUSE_HOTKEY -bool wxWindowBase::RegisterHotKey(int hotkeyId, int modifiers, int virtualKeyCode) + +bool +wxWindowBase::RegisterHotKey(int WXUNUSED(hotkeyId), + int WXUNUSED(modifiers), + int WXUNUSED(keycode)) { // not implemented return false; } -bool wxWindowBase::UnregisterHotKey(int hotkeyId) +bool wxWindowBase::UnregisterHotKey(int WXUNUSED(hotkeyId)) { // not implemented return false; } -#endif + +#endif // wxUSE_HOTKEY void wxWindowBase::SendDestroyEvent() { diff --git a/src/msw/window.cpp b/src/msw/window.cpp index e910670307..df95abf3a7 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -2170,21 +2170,21 @@ long wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam break; case WM_MOVING: - { - LPRECT pRect = (LPRECT)lParam; - wxRect rc; - rc.SetLeft(pRect->left); - rc.SetTop(pRect->top); - rc.SetRight(pRect->right); - rc.SetBottom(pRect->bottom); - processed = HandleMoving(rc); - if (processed) { - pRect->left = rc.GetLeft(); - pRect->top = rc.GetTop(); - pRect->right = rc.GetRight(); - pRect->bottom = rc.GetBottom(); - } - } + { + LPRECT pRect = (LPRECT)lParam; + wxRect rc; + rc.SetLeft(pRect->left); + rc.SetTop(pRect->top); + rc.SetRight(pRect->right); + rc.SetBottom(pRect->bottom); + processed = HandleMoving(rc); + if (processed) { + pRect->left = rc.GetLeft(); + pRect->top = rc.GetTop(); + pRect->right = rc.GetRight(); + pRect->bottom = rc.GetBottom(); + } + } break; case WM_SIZE: @@ -2553,7 +2553,7 @@ long wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam case WM_HOTKEY: processed = HandleHotKey((WORD)wParam, lParam); break; -#endif +#endif // wxUSE_HOTKEY case WM_HSCROLL: case WM_VSCROLL: @@ -5421,49 +5421,56 @@ wxPoint wxGetMousePosition() } #if wxUSE_HOTKEY -bool wxWindowMSW::RegisterHotKey(int hotkeyId, int modifiers, int virtualKeyCode) + +bool wxWindowMSW::RegisterHotKey(int hotkeyId, int modifiers, int keycode) { UINT win_modifiers=0; - if (modifiers & wxMOD_ALT) - win_modifiers|=MOD_ALT; - if (modifiers & wxMOD_SHIFT) - win_modifiers|=MOD_SHIFT; - if (modifiers & wxMOD_CONTROL) - win_modifiers|=MOD_CONTROL; - if (modifiers & wxMOD_WIN) - win_modifiers|=MOD_WIN; + if ( modifiers & wxMOD_ALT ) + win_modifiers |= MOD_ALT; + if ( modifiers & wxMOD_SHIFT ) + win_modifiers |= MOD_SHIFT; + if ( modifiers & wxMOD_CONTROL ) + win_modifiers |= MOD_CONTROL; + if ( modifiers & wxMOD_WIN ) + win_modifiers |= MOD_WIN; + + if ( !::RegisterHotKey(GetHwnd(), hotkeyId, win_modifiers, keycode) ) + { + wxLogLastError(_T("RegisterHotKey")); - return ::RegisterHotKey(GetHwnd(), hotkeyId, win_modifiers, virtualKeyCode)!=FALSE; + return FALSE; + } + + return TRUE; } bool wxWindowMSW::UnregisterHotKey(int hotkeyId) { - return ::UnregisterHotKey(GetHwnd(), hotkeyId)!=FALSE; + if ( !::UnregisterHotKey(GetHwnd(), hotkeyId) ) + { + wxLogLastError(_T("UnregisterHotKey")); + + return FALSE; + } + + return TRUE; } bool wxWindowMSW::HandleHotKey(WXWPARAM wParam, WXLPARAM lParam) { - int hotkeyId=wParam; - int virtualKey=HIWORD(lParam); - int win_modifiers=LOWORD(lParam); - /* - wxHotkeyModifier modifiers=wxMOD_NONE; - if (win_modifiers & MOD_ALT) - modifiers|=wxMOD_ALT; - if (win_modifiers & MOD_SHIFT) - modifiers|=wxMOD_SHIFT; - if (win_modifiers & MOD_CONTROL) - modifiers|=wxMOD_CONTROL; - if (win_modifiers & MOD_WIN) - modifiers|=wxMOD_WIN; -*/ + int hotkeyId = wParam; + int virtualKey = HIWORD(lParam); + int win_modifiers = LOWORD(lParam); + wxKeyEvent event(CreateKeyEvent(wxEVT_HOTKEY, virtualKey, wParam, lParam)); event.SetId(hotkeyId); event.m_shiftDown = (win_modifiers & MOD_SHIFT) != 0; event.m_controlDown = (win_modifiers & MOD_CONTROL) != 0; event.m_altDown = (win_modifiers & MOD_ALT) != 0; event.m_metaDown = (win_modifiers & MOD_WIN) != 0; - return GetEventHandler()->ProcessEvent(event); + + return GetEventHandler()->ProcessEvent(event); } -#endif + +#endif // wxUSE_HOTKEY -- 2.45.2