diff --git a/include/wx/filedlgcustomize.h b/include/wx/filedlgcustomize.h index b088cce6a1..7898b3dcc2 100644 --- a/include/wx/filedlgcustomize.h +++ b/include/wx/filedlgcustomize.h @@ -130,7 +130,7 @@ class wxFileDialogCustomize public: wxFileDialogButton* AddButton(const wxString& label); wxFileDialogCheckBox* AddCheckBox(const wxString& label); - wxFileDialogTextCtrl* AddTextCtrl(); + wxFileDialogTextCtrl* AddTextCtrl(const wxString& label = wxString()); wxFileDialogStaticText* AddStaticText(const wxString& label); ~wxFileDialogCustomize(); diff --git a/include/wx/private/filedlgcustomize.h b/include/wx/private/filedlgcustomize.h index d7c222951d..4523941842 100644 --- a/include/wx/private/filedlgcustomize.h +++ b/include/wx/private/filedlgcustomize.h @@ -58,7 +58,7 @@ class wxFileDialogCustomizeImpl public: virtual wxFileDialogButtonImpl* AddButton(const wxString& label) = 0; virtual wxFileDialogCheckBoxImpl* AddCheckBox(const wxString& label) = 0; - virtual wxFileDialogTextCtrlImpl* AddTextCtrl() = 0; + virtual wxFileDialogTextCtrlImpl* AddTextCtrl(const wxString& label) = 0; virtual wxFileDialogStaticTextImpl* AddStaticText(const wxString& label) = 0; virtual ~wxFileDialogCustomizeImpl(); diff --git a/samples/dialogs/dialogs.cpp b/samples/dialogs/dialogs.cpp index e7d0f25011..8886eb0ae9 100644 --- a/samples/dialogs/dialogs.cpp +++ b/samples/dialogs/dialogs.cpp @@ -1691,8 +1691,7 @@ public: // Note: all the pointers created here cease to be valid once // ShowModal() returns, TransferDataFromCustomControls() is the latest // moment when they can still be used. - customizer.AddStaticText("Just some extra text:"); - m_text = customizer.AddTextCtrl(); + m_text = customizer.AddTextCtrl("Just some extra text:"); m_cb = customizer.AddCheckBox("Enable Custom Button"); m_cb->Bind(wxEVT_CHECKBOX, &MyCustomizeHook::OnCheckBox, this); m_btn = customizer.AddButton("Custom Button"); diff --git a/src/common/fldlgcmn.cpp b/src/common/fldlgcmn.cpp index 6606ea8b8e..5dfc24f0d8 100644 --- a/src/common/fldlgcmn.cpp +++ b/src/common/fldlgcmn.cpp @@ -206,9 +206,9 @@ wxFileDialogCustomize::AddCheckBox(const wxString& label) } wxFileDialogTextCtrl* -wxFileDialogCustomize::AddTextCtrl() +wxFileDialogCustomize::AddTextCtrl(const wxString& label) { - return StoreAndReturn(new wxFileDialogTextCtrl(m_impl->AddTextCtrl())); + return StoreAndReturn(new wxFileDialogTextCtrl(m_impl->AddTextCtrl(label))); } wxFileDialogStaticText* diff --git a/src/msw/filedlg.cpp b/src/msw/filedlg.cpp index 57bbdc21f6..94edf19a05 100644 --- a/src/msw/filedlg.cpp +++ b/src/msw/filedlg.cpp @@ -378,7 +378,8 @@ public: wxFileDialogCustomizeFDC() : wxFileDialogCustomize(this) { - m_lastId = 0; + m_lastId = + m_lastAuxId = 0; } bool Initialize(IFileDialog* fileDialog) @@ -433,15 +434,31 @@ public: return new wxFileDialogCheckBoxImplFDC(m_fdc, m_lastId); } - wxFileDialogTextCtrlImpl* AddTextCtrl() wxOVERRIDE + wxFileDialogTextCtrlImpl* AddTextCtrl(const wxString& label) wxOVERRIDE { - HRESULT hr = m_fdc->AddEditBox(++m_lastId, L""); + HRESULT hr; + + if ( !label.empty() ) + { + hr = m_fdc->StartVisualGroup(--m_lastAuxId, label.wc_str()); + if ( FAILED(hr) ) + wxLogApiError(wxS("IFileDialogCustomize::StartVisualGroup"), hr); + } + + hr = m_fdc->AddEditBox(++m_lastId, L""); if ( FAILED(hr) ) { wxLogApiError(wxS("IFileDialogCustomize::AddEditBox"), hr); return NULL; } + if ( !label.empty() ) + { + hr = m_fdc->EndVisualGroup(); + if ( FAILED(hr) ) + wxLogApiError(wxS("IFileDialogCustomize::EndVisualGroup"), hr); + } + return new wxFileDialogTextCtrlImplFDC(m_fdc, m_lastId); } @@ -459,7 +476,15 @@ public: private: wxCOMPtr m_fdc; + + // IDs used for the custom controls returned from the public AddXXX() + // functions: they are positive and must be consecutive in order to allow + // accessing the correspond element of m_controls later, see FindControl(). DWORD m_lastId; + + // IDs used for any other controls, they're negative (which means they + // decrement from USHORT_MAX down). + DWORD m_lastAuxId; }; #endif // wxUSE_IFILEOPENDIALOG