From 1fdf858b87878bb6c52c06547a199ce9d9ab2b87 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Wed, 21 May 2003 18:43:03 +0000 Subject: [PATCH] Applied patch [ 740012 ] GetKeyState returns 16-Bit value on WindowsNT git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20683 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/private.h | 10 ++++++++-- src/msw/treectrl.cpp | 5 ++++- src/msw/window.cpp | 5 ++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/include/wx/msw/private.h b/include/wx/msw/private.h index e3cb8dbc7b..c017a715f7 100644 --- a/include/wx/msw/private.h +++ b/include/wx/msw/private.h @@ -286,12 +286,18 @@ HCURSOR wxBitmapToHCURSOR(const wxBitmap& bmp, int hotSpotX, int hotSpotY); // get the current state of SHIFT/CTRL keys inline bool wxIsShiftDown() { - return (::GetKeyState(VK_SHIFT) & 0x100) != 0; +// return (::GetKeyState(VK_SHIFT) & 0x100) != 0; + // Returns different negative values on WinME and WinNT, + // so simply test for negative value. + return ::GetKeyState(VK_SHIFT) < 0; } inline bool wxIsCtrlDown() { - return (::GetKeyState(VK_CONTROL) & 0x100) != 0; +// return (::GetKeyState(VK_CONTROL) & 0x100) != 0; + // Returns different negative values on WinME and WinNT, + // so simply test for negative value. + return ::GetKeyState(VK_CONTROL) < 0; } // wrapper around GetWindowRect() and GetClientRect() APIs doing error checking diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index a579355d50..d412e56ef7 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -2398,7 +2398,10 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) // similar to the ones from a "real" WM_KEYDOWN so that // CreateKeyEvent() works correctly WXLPARAM lParam = - (::GetKeyState(VK_MENU) & 0x100 ? KF_ALTDOWN : 0) << 16; +// (::GetKeyState(VK_MENU) & 0x100 ? KF_ALTDOWN : 0) << 16; + // Returns different negative values on WinME and WinNT, + // so simply test for negative value. + (::GetKeyState(VK_MENU) < 0 ? KF_ALTDOWN : 0) << 16; WXWPARAM wParam = info->wVKey; diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 0374b532cd..e9772cc34a 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -3965,7 +3965,10 @@ void wxWindowMSW::InitMouseEvent(wxMouseEvent& event, event.m_leftDown = (flags & MK_LBUTTON) != 0; event.m_middleDown = (flags & MK_MBUTTON) != 0; event.m_rightDown = (flags & MK_RBUTTON) != 0; - event.m_altDown = (::GetKeyState(VK_MENU) & 0x80000000) != 0; + // event.m_altDown = (::GetKeyState(VK_MENU) & 0x80000000) != 0; + // Returns different negative values on WinME and WinNT, + // so simply test for negative value. + event.m_altDown = ::GetKeyState(VK_MENU) < 0; event.SetTimestamp(s_currentMsg.time); event.m_eventObject = this; -- 2.45.2