git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15669 
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
     
     m_isBeingDeleted = TRUE;
 
+#ifndef __WXUNIVERSAL__
+    // VS: make sure there's no wxFrame with last focus set to us:
+    for ( wxWindow *win = GetParent(); win; win = win->GetParent() )
+    {
+        wxFrame *frame = wxDynamicCast(win, wxFrame);
+        if ( frame )
+        {
+            if ( frame->GetLastFocus() == this )
+            {
+                frame->SetLastFocus((wxWindow*)NULL);
+            }
+            break;
+        }
+    }
+#endif // __WXUNIVERSAL__
+
     if ( s_lastMouseWindow == this )
     {
         s_lastMouseWindow = NULL ;
 
     
     m_isBeingDeleted = TRUE;
 
+#ifndef __WXUNIVERSAL__
+    // VS: make sure there's no wxFrame with last focus set to us:
+    for ( wxWindow *win = GetParent(); win; win = win->GetParent() )
+    {
+        wxFrame *frame = wxDynamicCast(win, wxFrame);
+        if ( frame )
+        {
+            if ( frame->GetLastFocus() == this )
+            {
+                frame->SetLastFocus((wxWindow*)NULL);
+            }
+            break;
+        }
+    }
+#endif // __WXUNIVERSAL__
+
     if ( s_lastMouseWindow == this )
     {
         s_lastMouseWindow = NULL ;