]> git.saurik.com Git - wxWidgets.git/commitdiff
simplify the code for extended flags handling fixing a rare bug with wxSTAY_ON_TOP...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 7 Oct 2007 22:11:55 +0000 (22:11 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 7 Oct 2007 22:11:55 +0000 (22:11 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49086 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/dialogs/dialogs.cpp
samples/dialogs/dialogs.h
src/msw/toplevel.cpp

index 7c7c6282c7611b6d6274c1bff03f27d7597bda07..18b12f67b88a2dc76c531dedb8255ffbfaa02f74 100644 (file)
@@ -168,6 +168,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
     EVT_MENU(DIALOGS_CENTRE_SCREEN,                 MyFrame::DlgCenteredScreen)
     EVT_MENU(DIALOGS_CENTRE_PARENT,                 MyFrame::DlgCenteredParent)
     EVT_MENU(DIALOGS_MINIFRAME,                     MyFrame::MiniFrame)
+    EVT_MENU(DIALOGS_ONTOP,                         MyFrame::DlgOnTop)
 
 #if wxUSE_STARTUP_TIPS
     EVT_MENU(DIALOGS_TIP,                           MyFrame::ShowTip)
@@ -390,6 +391,7 @@ bool MyApp::OnInit()
     dialogs_menu->Append(DIALOGS_CENTRE_SCREEN, _T("Centered on &screen\tShift-Ctrl-1"));
     dialogs_menu->Append(DIALOGS_CENTRE_PARENT, _T("Centered on &parent\tShift-Ctrl-2"));
     dialogs_menu->Append(DIALOGS_MINIFRAME, _T("&Mini frame"));
+    dialogs_menu->Append(DIALOGS_ONTOP, _T("Dialog staying on &top"));
     menuDlg->Append(wxID_ANY, _T("&Generic dialogs"), dialogs_menu);
 
 #if USE_SETTINGS_DIALOG
@@ -1057,6 +1059,15 @@ void MyFrame::MiniFrame(wxCommandEvent& WXUNUSED(event))
     frame->Show();
 }
 
+void MyFrame::DlgOnTop(wxCommandEvent& WXUNUSED(event))
+{
+    wxDialog dlg(this, wxID_ANY, _T("Dialog staying on top of other windows"),
+                 wxDefaultPosition, wxSize(300, 100),
+                 wxDEFAULT_DIALOG_STYLE | wxSTAY_ON_TOP);
+    (new wxButton(&dlg, wxID_OK, _T("Close")))->Centre();
+    dlg.ShowModal();
+}
+
 #if wxUSE_STARTUP_TIPS
 void MyFrame::ShowTip(wxCommandEvent& WXUNUSED(event))
 {
index f24154b8e94f7a9377f5fe4fec7edcd0413545ef..62ff683de9c16048b7420425b4b53f183efaa063 100644 (file)
@@ -268,6 +268,7 @@ public:
     void DlgCenteredScreen(wxCommandEvent& event);
     void DlgCenteredParent(wxCommandEvent& event);
     void MiniFrame(wxCommandEvent& event);
+    void DlgOnTop(wxCommandEvent& event);
 
 #if wxUSE_PROGRESSDLG
     void ShowProgress(wxCommandEvent& event);
@@ -366,6 +367,7 @@ enum
     DIALOGS_CENTRE_SCREEN,
     DIALOGS_CENTRE_PARENT,
     DIALOGS_MINIFRAME,
+    DIALOGS_ONTOP,
     DIALOGS_MODELESS_BTN,
     DIALOGS_PROGRESS,
     DIALOGS_ABOUTDLG_SIMPLE,
index bfd3f56b4d3187af9f10712c61a7210004be10eb..86ac85d33e99f3dcd0cfa6fe738dd2409a64e3b6 100644 (file)
@@ -423,25 +423,10 @@ bool wxTopLevelWindowMSW::CreateDialog(const void *dlgTemplate,
         return false;
     }
 
-    WXDWORD exflags;
-    (void)MSWGetCreateWindowFlags(&exflags);
-
-    if ( exflags )
-    {
-        ::SetWindowLong(GetHwnd(), GWL_EXSTYLE, exflags);
-        ::SetWindowPos(GetHwnd(),
-                       exflags & WS_EX_TOPMOST ? HWND_TOPMOST : 0,
-                       0, 0, 0, 0,
-                       SWP_NOSIZE |
-                       SWP_NOMOVE |
-                       (exflags & WS_EX_TOPMOST ? 0 : SWP_NOZORDER) |
-                       SWP_NOACTIVATE);
-    }
-
 #if !defined(__WXWINCE__)
     // For some reason, the system menu is activated when we use the
     // WS_EX_CONTEXTHELP style, so let's set a reasonable icon
-    if ( exflags & WS_EX_CONTEXTHELP )
+    if ( HasExtraStyle(wxWS_EX_CONTEXTHELP) )
     {
         wxFrame *winTop = wxDynamicCast(wxTheApp->GetTopWindow(), wxFrame);
         if ( winTop )
@@ -455,7 +440,7 @@ bool wxTopLevelWindowMSW::CreateDialog(const void *dlgTemplate,
             }
         }
     }
-#endif
+#endif // !__WXWINCE__
 
     // move the dialog to its initial position without forcing repainting
     int x, y, w, h;
@@ -561,7 +546,7 @@ bool wxTopLevelWindowMSW::Create(wxWindow *parent,
 
         // reuse the code in MSWGetStyle() but correct the results slightly for
         // the dialog
-        dlgTemplate->style = MSWGetStyle(style, NULL);
+        dlgTemplate->style = MSWGetStyle(style, &dlgTemplate->dwExtendedStyle);
 
         // all dialogs are popups
         dlgTemplate->style |= WS_POPUP;