diff --git a/interface/wx/filedlgcustomize.h b/interface/wx/filedlgcustomize.h index e49bbbbf44..818eedc878 100644 --- a/interface/wx/filedlgcustomize.h +++ b/interface/wx/filedlgcustomize.h @@ -331,6 +331,7 @@ public: // This object may be destroyed before the dialog, but must remain // alive until ShowModal() returns. EncryptHook customizeHook; + dialog.SetCustomizeHook(customHook); if ( dialog.ShowModal() == wxID_OK ) { diff --git a/samples/dialogs/dialogs.cpp b/samples/dialogs/dialogs.cpp index 81458a6d06..581f9428d3 100644 --- a/samples/dialogs/dialogs.cpp +++ b/samples/dialogs/dialogs.cpp @@ -2009,10 +2009,42 @@ void MyFrame::FileSave(wxCommandEvent& WXUNUSED(event) ) dialog.SetFilterIndex(1); + // This tests the (even more simplified) example from the docs. + class EncryptHook : public wxFileDialogCustomizeHook + { + public: + EncryptHook() + : m_encrypt(false) + { + } + + void AddCustomControls(wxFileDialogCustomize& customizer) wxOVERRIDE + { + m_checkbox = customizer.AddCheckBox("Encrypt"); + } + + void TransferDataFromCustomControls() wxOVERRIDE + { + m_encrypt = m_checkbox->GetValue(); + } + + bool Encrypt() const { return m_encrypt; } + + private: + wxFileDialogCheckBox* m_checkbox; + + bool m_encrypt; + }; + + EncryptHook customHook; + dialog.SetCustomizeHook(customHook); + if (dialog.ShowModal() == wxID_OK) { - wxLogMessage("%s, filter %d", - dialog.GetPath(), dialog.GetFilterIndex()); + wxLogMessage("%s, filter %d%s", + dialog.GetPath(), + dialog.GetFilterIndex(), + customHook.Encrypt() ? ", encrypt" : ""); } }