diff --git a/samples/dialogs/dialogs.cpp b/samples/dialogs/dialogs.cpp index 8886eb0ae9..5f43f3c362 100644 --- a/samples/dialogs/dialogs.cpp +++ b/samples/dialogs/dialogs.cpp @@ -1680,7 +1680,10 @@ static wxWindow* createMyExtraPanel(wxWindow *parent) class MyCustomizeHook : public wxFileDialogCustomizeHook { public: - explicit MyCustomizeHook(wxFileDialog& dialog) + // Normally we would just use wxFileDialog, but this sample allows using + // both the real wxFileDialog and wxGenericFileDialog, so allow passing + // either of them here. + explicit MyCustomizeHook(wxFileDialogBase& dialog) : m_dialog(&dialog) { } @@ -1733,7 +1736,7 @@ private: wxOK | wxICON_INFORMATION, m_dialog); } - wxFileDialog* const m_dialog; + wxFileDialogBase* const m_dialog; wxFileDialogButton* m_btn; wxFileDialogCheckBox* m_cb; @@ -2005,7 +2008,8 @@ void MyFrame::FileOpenGeneric(wxCommandEvent& WXUNUSED(event) ) "C++ files (*.cpp;*.h)|*.cpp;*.h" ); - dialog.SetExtraControlCreator(&createMyExtraPanel); + MyCustomizeHook myCustomizer(dialog); + dialog.SetCustomizeHook(myCustomizer); dialog.SetDirectory(wxGetHomeDir()); if (dialog.ShowModal() == wxID_OK) @@ -2013,10 +2017,12 @@ void MyFrame::FileOpenGeneric(wxCommandEvent& WXUNUSED(event) ) wxString info; info.Printf("Full file name: %s\n" "Path: %s\n" - "Name: %s", + "Name: %s\n" + "Custom window: %s", dialog.GetPath(), dialog.GetDirectory(), - dialog.GetFilename()); + dialog.GetFilename(), + myCustomizer.GetInfo()); wxMessageDialog dialog2(this, info, "Selected file"); dialog2.ShowModal(); } diff --git a/src/generic/filedlgg.cpp b/src/generic/filedlgg.cpp index 904c55ad8d..c32509dfb0 100644 --- a/src/generic/filedlgg.cpp +++ b/src/generic/filedlgg.cpp @@ -301,7 +301,17 @@ int wxGenericFileDialog::ShowModal() m_filectrl->SetDirectory(m_dir); - return wxDialog::ShowModal(); + const int rc = wxDialog::ShowModal(); + + // Destroy the extra controls before ShowModal() returns for consistency + // with the native implementations. + if (m_extraControl) + { + m_extraControl->Destroy(); + m_extraControl = NULL; + } + + return rc; } bool wxGenericFileDialog::Show( bool show ) @@ -402,6 +412,8 @@ void wxGenericFileDialog::OnUpdateButtonsUI(wxUpdateUIEvent& event) // wxFileCtrl ctor itself can generate idle events, so we need this test if ( m_filectrl ) event.Enable( !IsTopMostDir(m_filectrl->GetShownDirectory()) ); + + UpdateExtraControlUI(); } #ifdef wxHAS_GENERIC_FILEDIALOG