]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/window.cpp
added missing return on error
[wxWidgets.git] / src / os2 / window.cpp
index 14abb69cd1ded9545938f0053f9af5bc38a3878a..26e94bc0cc10c6e7ea3114bde094d5b9ee2020de 100644 (file)
@@ -306,6 +306,16 @@ wxWindow::~wxWindow()
     m_isBeingDeleted = TRUE;
 
     OS2DetachWindowMenu();
+    for (wxWindow* pWin = GetParent(); pWin; pWin = pWin->GetParent())
+    {
+        wxFrame*                    pFrame = wxDynamicCast(pWin, wxFrame);
+
+        if (pFrame)
+        {
+            if (pFrame->GetLastFocus() == this)
+                pFrame->SetLastFocus((wxWindow*)NULL);
+        }
+    }
     if (m_parent)
         m_parent->RemoveChild(this);
     DestroyChildren();
@@ -1438,6 +1448,17 @@ void wxWindow::DoMoveWindow(
 , int                               nHeight
 )
 {
+    RECTL                           vRect;
+    HWND                            hParent;
+    wxWindow*                       pParent = GetParent();
+
+    if (pParent)
+        hParent = GetWinHwnd(pParent);
+    else
+        hParent = HWND_DESKTOP;
+    ::WinQueryWindowRect(hParent, &vRect);
+    nY = vRect.yTop - (nY + nHeight);
+
     if ( !::WinSetWindowPos( GetHwnd()
                             ,HWND_TOP
                             ,(LONG)nX
@@ -1789,6 +1810,26 @@ void wxWindow::GetCaretPos(
 // popup menu
 // ---------------------------------------------------------------------------
 
+static void wxYieldForCommandsOnly()
+{
+    //
+    // Peek all WM_COMMANDs (it will always return WM_QUIT too but we don't
+    // want to process it here)
+    //
+    QMSG                            vMsg;
+
+    while (::WinPeekMsg( vHabmain
+                        ,&vMsg
+                        ,(HWND)0
+                        ,WM_COMMAND
+                        ,WM_COMMAND
+                        ,PM_REMOVE
+                       ) && vMsg.msg != WM_QUIT)
+    {
+        wxTheApp->DoMessage((WXMSG*)&vMsg);
+    }
+}
+
 bool wxWindow::DoPopupMenu(
   wxMenu*                           pMenu
 , int                               nX
@@ -1815,7 +1856,14 @@ bool wxWindow::DoPopupMenu(
                    ,0L
                    ,PU_MOUSEBUTTON2DOWN | PU_MOUSEBUTTON2 | PU_KEYBOARD
                   );
-    wxYield();
+    // we need to do it righ now as otherwise the events are never going to be
+    // sent to wxCurrentPopupMenu from HandleCommand()
+    //
+    // note that even eliminating (ugly) wxCurrentPopupMenu global wouldn't
+    // help and we'd still need wxYieldForCommandsOnly() as the menu may be
+    // destroyed as soon as we return (it can be a local variable in the caller
+    // for example) and so we do need to process the event immediately
+    wxYieldForCommandsOnly();
     wxCurrentPopupMenu = NULL;
 
     pMenu->SetInvokingWindow(NULL);
@@ -3338,6 +3386,7 @@ bool wxWindow::HandlePaint()
                               ,0L
                               ,&vLineBundle
                              );
+                ::WinQueryWindowRect(GetHwnd(), &vRect);
                 wxDrawBorder( hPS
                              ,vRect
                              ,m_dwExStyle