]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/window.cpp
A few tweaks and cleanups
[wxWidgets.git] / src / msw / window.cpp
index b7ed11bbb67ced9f68befaf653daf92bbe48b74c..77589902e52de74badfdc01b09e54c06d7afcf75 100644 (file)
@@ -2036,10 +2036,18 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg)
         }
 #endif // 1/0
 
-        if ( ::IsDialogMessage(GetHwnd(), msg) )
+        // we handle VK_ESCAPE ourselves in wxDialog::OnCharHook() and we
+        // shouldn't let IsDialogMessage() get it as it _always_ eats the
+        // message even when there is no cancel button and when the message is
+        // needed by the control itself: in particular, it prevents the tree in
+        // place edit control from being closed with Escape in a dialog
+        if ( msg->message != WM_KEYDOWN || msg->wParam != VK_ESCAPE )
         {
-            // IsDialogMessage() did something...
-            return TRUE;
+            if ( ::IsDialogMessage(GetHwnd(), msg) )
+            {
+                // IsDialogMessage() did something...
+                return TRUE;
+            }
         }
     }
 #endif // __WXUNIVERSAL__
@@ -2549,18 +2557,8 @@ long wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam
 #endif // VK_APPS
 
                 default:
-                    if ( m_lastKeydownProcessed )
-                    {
-                        // The key was handled in the EVT_KEY_DOWN and handling
-                        // a key in an EVT_KEY_DOWN handler is meant, by
-                        // design, to prevent EVT_CHARs from happening
-                        m_lastKeydownProcessed = FALSE;
-                        processed = TRUE;
-                    }
-                    else // do generate a CHAR event
-                    {
-                        processed = HandleChar((WORD)wParam, lParam);
-                    }
+                    // do generate a CHAR event
+                    processed = HandleChar((WORD)wParam, lParam);
 
             }
             break;
@@ -2586,7 +2584,18 @@ long wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam
 
         case WM_SYSCHAR:
         case WM_CHAR: // Always an ASCII character
-            processed = HandleChar((WORD)wParam, lParam, TRUE);
+            if ( m_lastKeydownProcessed )
+            {
+                // The key was handled in the EVT_KEY_DOWN and handling
+                // a key in an EVT_KEY_DOWN handler is meant, by
+                // design, to prevent EVT_CHARs from happening
+                m_lastKeydownProcessed = FALSE;
+                processed = TRUE;
+            }
+            else
+            {
+                processed = HandleChar((WORD)wParam, lParam, TRUE);
+            }
             break;
 
         case WM_HSCROLL:
@@ -2646,6 +2655,10 @@ long wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam
             processed = HandlePaletteChanged((WXHWND) (HWND) wParam);
             break;
 
+        case WM_CAPTURECHANGED:
+            processed = HandleCaptureChanged((WXHWND) (HWND) lParam);
+            break;
+
         case WM_QUERYNEWPALETTE:
             processed = HandleQueryNewPalette();
             break;
@@ -3510,6 +3523,14 @@ bool wxWindowMSW::HandlePaletteChanged(WXHWND hWndPalChange)
     return GetEventHandler()->ProcessEvent(event);
 }
 
+bool wxWindowMSW::HandleCaptureChanged(WXHWND hWndGainedCapture)
+{
+    wxMouseCaptureChangedEvent event(GetId(), wxFindWinFromHandle(hWndGainedCapture));
+    event.SetEventObject(this);
+
+    return GetEventHandler()->ProcessEvent(event);
+}
+
 bool wxWindowMSW::HandleQueryNewPalette()
 {
 
@@ -3775,9 +3796,13 @@ bool wxWindowMSW::HandleMove(int x, int y)
     return GetEventHandler()->ProcessEvent(event);
 }
 
-bool wxWindowMSW::HandleSize(int w, int h, WXUINT WXUNUSED(flag))
+bool wxWindowMSW::HandleSize(int WXUNUSED(w), int WXUNUSED(h),
+                             WXUINT WXUNUSED(flag))
 {
-    wxSizeEvent event(wxSize(w, h), m_windowId);
+    // don't use w and h parameters as they specify the client size while
+    // according to the docs EVT_SIZE handler is supposed to receive the total
+    // size
+    wxSizeEvent event(GetSize(), m_windowId);
     event.SetEventObject(this);
 
     return GetEventHandler()->ProcessEvent(event);
@@ -4266,7 +4291,7 @@ bool wxWindowMSW::HandleJoystickEvent(WXUINT msg, int x, int y, WXUINT flags)
 // ---------------------------------------------------------------------------
 
 bool wxWindowMSW::MSWOnScroll(int orientation, WXWORD wParam,
-                           WXWORD pos, WXHWND control)
+                              WXWORD pos, WXHWND control)
 {
     if ( control )
     {