]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/window.cpp
Some more bug reports
[wxWidgets.git] / src / msw / window.cpp
index 5592a346bc89a8b25d0ae9e20638d2dad070d361..56c491347362357e384a8b3fd54227f9eaea1054 100644 (file)
@@ -74,8 +74,8 @@
 #include "wx/intl.h"
 #include "wx/log.h"
 
-
 #include "wx/textctrl.h"
+#include "wx/notebook.h"
 
 #include <string.h>
 
@@ -1469,6 +1469,10 @@ bool wxWindow::MSWProcessMessage(WXMSG* pMsg)
     {
         // intercept dialog navigation keys
         MSG *msg = (MSG *)pMsg;
+
+        // here we try to do all the job which ::IsDialogMessage() usually does
+        // internally
+#if 0
         bool bProcess = TRUE;
         if ( msg->message != WM_KEYDOWN )
             bProcess = FALSE;
@@ -1586,6 +1590,36 @@ bool wxWindow::MSWProcessMessage(WXMSG* pMsg)
                 }
             }
         }
+#else
+        // let ::IsDialogMessage() do almost everything and handle just the
+        // things it doesn't here: Ctrl-TAB for switching notebook pages
+        if ( msg->message == WM_KEYDOWN )
+        {
+            // don't process system keys here
+            if ( !(HIWORD(msg->lParam) & KF_ALTDOWN) )
+            {
+                if ( (msg->wParam == VK_TAB) &&
+                     (::GetKeyState(VK_CONTROL) & 0x100) != 0 )
+                {
+                    // find the first notebook parent and change its page
+                    wxWindow *win = this;
+                    wxNotebook *nbook = NULL;
+                    while ( win && !nbook )
+                    {
+                        nbook = wxDynamicCast(win, wxNotebook);
+                        win = win->GetParent();
+                    }
+
+                    if ( nbook )
+                    {
+                        bool forward = !(::GetKeyState(VK_SHIFT) & 0x100);
+
+                        nbook->AdvanceSelection(forward);
+                    }
+                }
+            }
+        }
+#endif // 0
 
         if ( ::IsDialogMessage(GetHwnd(), msg) )
             return TRUE;
@@ -2948,10 +2982,16 @@ bool wxWindow::HandleCommand(WXWORD id, WXWORD cmd, WXHWND control)
         return popupMenu->MSWCommand(cmd, id);
     }
 
-    // must cast to a signed type before comparing with other ids!
-    wxWindow *win = FindItem((signed short)id);
-    if ( !win )
+    wxWindow *win;
+    if ( cmd == 0 || cmd == 1 ) // menu or accel - use id
+    {
+        // must cast to a signed type before comparing with other ids!
+        win = FindItem((signed short)id);
+    }
+    else
     {
+        // find it from HWND - this works even with the broken programs using
+        // the same ids for different controls
         win = wxFindWinFromHandle(control);
     }