]> git.saurik.com Git - wxWidgets.git/commitdiff
fix showing keyboard cues under Win2k/XP
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 3 Sep 2005 23:00:22 +0000 (23:00 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 3 Sep 2005 23:00:22 +0000 (23:00 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35417 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
include/wx/msw/window.h
src/msw/toplevel.cpp
src/msw/window.cpp

index 2630804b1cfb762b1ffe470bc75c9d5429faa7b3..06424af1bc3232610526552c192ecf2bb87a4d9b 100644 (file)
@@ -151,6 +151,7 @@ wxMSW:
 - Fixed ownerdrawn multiline buttons.
 - wxCheckListBox item background fixed.
 - Fixed error when trying to read a value from key not accessible for writing.
+- Fixed keyboard cue visibility issues under Windows 2000/XP
 
 wxWinCE:
 
index 10e33d8b1c180351b2c68391acadb37f86043224..520e9db2a96fe3bba698c4ec8b20d4f530475319 100644 (file)
@@ -491,6 +491,9 @@ protected:
     // the background, false otherwise (i.e. the system should erase it)
     bool DoEraseBackground(WXHDC hDC);
 
+    // generate WM_UPDATEUISTATE if it's needed for the OS we're running under
+    void MSWUpdateUIState();
+
 private:
     // common part of all ctors
     void Init();
index 2b7fdf4a48676b94d74395dfbc7ac36bf1a70a98..7048c01b18627c128cb0aa33613b06df962cecca 100644 (file)
@@ -527,21 +527,13 @@ bool wxTopLevelWindowMSW::Create(wxWindow *parent,
     }
 #endif
 
-    // for some reason we need to manually send ourselves this message as
-    // otherwise the mnemonics are always shown -- even if they're configured
-    // to be hidden until "Alt" is pressed in the control panel
-    //
-    // this could indicate a bug somewhere else but for now this is the only
-    // fix we have
+    // for standard dialogs the dialog manager generates WM_CHANGEUISTATE
+    // itself but for custom windows we have to do it ourselves in order to
+    // make the keyboard indicators (such as underlines for accelerators and
+    // focus rectangles) work under Win2k+
     if ( ret )
     {
-        ::SendMessage
-        (
-            GetHwnd(),
-            WM_UPDATEUISTATE,
-            MAKEWPARAM(UIS_INITIALIZE, UISF_HIDEFOCUS | UISF_HIDEACCEL),
-            0
-        );
+        MSWUpdateUIState();
     }
 
     // Note: if we include PocketPC in this test, dialogs can fail to show up,
index 64bf883fc57404a29a6b6bc3308e33c6f11806ec..2067b22fa50380170deec837789f9c873568fc34 100644 (file)
@@ -800,7 +800,7 @@ bool wxWindowMSW::SetCursor(const wxCursor& cursor)
     return true;
 }
 
-void wxWindowMSW::WarpPointer (int x, int y)
+void wxWindowMSW::WarpPointer(int x, int y)
 {
     ClientToScreen(&x, &y);
 
@@ -810,6 +810,29 @@ void wxWindowMSW::WarpPointer (int x, int y)
     }
 }
 
+void wxWindowMSW::MSWUpdateUIState()
+{
+    // WM_UPDATEUISTATE only appeared in Windows 2000 so it can do us no good
+    // to use it on older systems -- and could possibly do some harm
+    static int s_needToUpdate = -1;
+    if ( s_needToUpdate == -1 )
+    {
+        int verMaj, verMin;
+        s_needToUpdate = wxGetOsVersion(&verMaj, &verMin) == wxWINDOWS_NT &&
+                            verMaj >= 5;
+    }
+
+    if ( s_needToUpdate )
+    {
+        // NB: it doesn't seem to matter what we put in wParam, whether we
+        //     include just one UISF_XXX or both, both are affected, no idea
+        //     why
+        ::SendMessage(GetHwnd(), WM_UPDATEUISTATE,
+                        MAKEWPARAM(UIS_INITIALIZE,
+                                   UISF_HIDEFOCUS | UISF_HIDEACCEL), 0);
+    }
+}
+
 // ---------------------------------------------------------------------------
 // scrolling stuff
 // ---------------------------------------------------------------------------
@@ -2061,6 +2084,12 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg)
 
                 if ( GetEventHandler()->ProcessEvent(event) )
                 {
+                    // as we don't call IsDialogMessage(), which would take of
+                    // this by default, we need to manually send this message
+                    // so that controls could change their appearance
+                    // appropriately
+                    MSWUpdateUIState();
+
                     return true;
                 }
             }