]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/window.cpp
Added AddGrab, RemoveGrab, IsGrabbed to wxTopLevelWindowGTK
[wxWidgets.git] / src / msw / window.cpp
index cf7c4277ac81302bc7927295f17fa2eb48cf5f58..d1638dcda51053e6bb621cf8918cb694b5b6a487 100644 (file)
@@ -312,10 +312,8 @@ void wxWindowMSW::Init()
     InitBase();
 
     // MSW specific
-    m_doubleClickAllowed = 0;
-
     m_isBeingDeleted = FALSE;
-    m_oldWndProc = 0;
+    m_oldWndProc = NULL;
     m_useCtl3D = FALSE;
     m_mouseInWindow = FALSE;
     m_lastKeydownProcessed = FALSE;
@@ -993,7 +991,10 @@ void wxWindowMSW::SubclassWin(WXHWND hWnd)
     }
     else
     {
-        // don't bother restoring it neither
+        // don't bother restoring it neither: this also makes it easy to
+        // implement IsOfStandardClass() method which returns TRUE for the
+        // standard controls and FALSE for the wxWindows own windows as it can
+        // simply check m_oldWndProc
         m_oldWndProc = NULL;
     }
 }
@@ -1915,14 +1916,7 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg)
         // here we try to do all the job which ::IsDialogMessage() usually does
         // internally
 #if 1
-        bool bProcess = TRUE;
-        if ( msg->message != WM_KEYDOWN )
-            bProcess = FALSE;
-
-        if ( bProcess && (HIWORD(msg->lParam) & KF_ALTDOWN) == KF_ALTDOWN )
-            bProcess = FALSE;
-
-        if ( bProcess )
+        if ( msg->message == WM_KEYDOWN )
         {
             bool bCtrlDown = wxIsCtrlDown();
             bool bShiftDown = wxIsShiftDown();
@@ -1939,6 +1933,8 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg)
             bool bForward = TRUE,
                  bWindowChange = FALSE;
 
+            // should we process this message specially?
+            bool bProcess = TRUE;
             switch ( msg->wParam )
             {
                 case VK_TAB:
@@ -2083,9 +2079,9 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg)
         // place edit control from being closed with Escape in a dialog
         if ( msg->message != WM_KEYDOWN || msg->wParam != VK_ESCAPE )
         {
-            // ::IsDialogMessage() can enter in an infinite loop when
-            // WS_EX_CONTROLPARENT is specified and the currently focused
-            // window is disabled or hidden, so don't call it in this case
+            // ::IsDialogMessage() can enter in an infinite loop when the
+            // currently focused window is disabled or hidden and its parent
+            // has WS_EX_CONTROLPARENT style, so don't call it in this case
             bool canSafelyCallIsDlgMsg = TRUE;
 
             HWND hwndFocus = ::GetFocus();
@@ -2100,6 +2096,14 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg)
                     break;
                 }
 
+                if ( !(::GetWindowLong(hwndFocus, GWL_STYLE) & WS_CHILD) )
+                {
+                    // it's a top level window, don't go further -- e.g. even
+                    // if the parent of a dialog is disabled, this doesn't
+                    // break navigation inside the dialog
+                    break;
+                }
+
                 hwndFocus = ::GetParent(hwndFocus);
             }
 
@@ -2442,28 +2446,36 @@ long wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam
                         break;
                 }
 
-                if (!processed)
+                if ( processed )
+                    break;
+
 #endif // __WXMICROWIN__
-                {
-                    // VZ: why do we need it here? DefWindowProc() is supposed
-                    //     to do this for us anyhow
-                    if ( message == WM_LBUTTONDOWN && AcceptsFocus() )
-                        SetFocus();
+                // VZ: if you find a situation when this is needed, tell
+                //     me about it, do *not* uncomment this code as it
+                //     causes other strange problems
+#if 0
+                if ( message == WM_LBUTTONDOWN && AcceptsFocus() )
+                    SetFocus();
+#endif // 0
 
-                    int x = GET_X_LPARAM(lParam),
-                        y = GET_Y_LPARAM(lParam);
+                int x = GET_X_LPARAM(lParam),
+                    y = GET_Y_LPARAM(lParam);
 
-                    // redirect the event to a static control if necessary
-                    if (this == GetCapture())
-                    {
-                        processed = HandleMouseEvent(message, x, y, wParam);
-                    }
-                    else
-                    {
-                        wxWindowMSW *win = FindWindowForMouseEvent(this, &x, &y); //TW:REQ:Univ
-                        processed = win->HandleMouseEvent(message, x, y, wParam);
-                    }
+                // redirect the event to a static control if necessary by
+                // finding one under mouse
+                wxWindowMSW *win;
+                if ( GetCapture() == this )
+                {
+                    // but don't do it if the mouse is captured by this window
+                    // because then it should really get this event itself
+                    win = this;
+                }
+                else
+                {
+                    win = FindWindowForMouseEvent(this, &x, &y);
                 }
+
+                processed = win->HandleMouseEvent(message, x, y, wParam);
             }
             break;
 
@@ -2527,11 +2539,19 @@ long wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam
 #endif // defined(WM_DRAWITEM)
 
         case WM_GETDLGCODE:
-            if ( GetWindowStyleFlag() & wxWANTS_CHARS )
+            if ( !IsOfStandardClass() )
             {
-                // want everything: i.e. all keys and WM_CHAR message
-                rc.result = DLGC_WANTARROWS | DLGC_WANTCHARS |
-                            DLGC_WANTTAB | DLGC_WANTMESSAGE;
+                // we always want to get the char events
+                rc.result = DLGC_WANTCHARS;
+
+                if ( GetWindowStyleFlag() & wxWANTS_CHARS )
+                {
+                    // in fact, we want everything
+                    rc.result |= DLGC_WANTARROWS |
+                                 DLGC_WANTTAB |
+                                 DLGC_WANTALLKEYS;
+                }
+
                 processed = TRUE;
             }
             //else: get the dlg code from the DefWindowProc()
@@ -2951,20 +2971,7 @@ bool wxWindowMSW::MSWCreate(const wxChar *wclass,
 
     // controlId is menu handle for the top level windows, so set it to 0
     // unless we're creating a child window
-    int controlId;
-    if ( style & WS_CHILD )
-    {
-        controlId = GetId();
-
-        if ( GetWindowStyleFlag() & wxCLIP_SIBLINGS )
-        {
-            style |= WS_CLIPSIBLINGS;
-        }
-    }
-    else // !child
-    {
-        controlId = 0;
-    }
+    int controlId = style & WS_CHILD ? GetId() : 0;
 
     // for each class "Foo" we have we also have "FooNR" ("no repaint") class
     // which is the same but without CS_[HV]REDRAW class styles so using it