Call MSWOnInitDone() when using IFileDialog too
This allows to use the new style dialog for the file dialogs for which Centre() or SetSize() had been called, as we can now position the window even when not using a hook function. As there is no IFileDialogEvents function corresponding to CDN_INITDONE notification, use the first call to OnTypeChange() instead.
This commit is contained in:
@@ -51,7 +51,7 @@ private:
|
||||
// called when the dialog is created
|
||||
void MSWOnInitDialogHook(WXHWND hwnd);
|
||||
|
||||
// called from the hook procedure on CDN_INITDONE reception
|
||||
// called when the dialog initialization is fully done
|
||||
void MSWOnInitDone(WXHWND hDlg);
|
||||
|
||||
// called when the currently selected file changes in the dialog
|
||||
|
||||
@@ -1741,6 +1741,8 @@ void MyFrame::FilesOpen(wxCommandEvent& WXUNUSED(event) )
|
||||
wxEmptyString, wxEmptyString, wildcards,
|
||||
wxFD_OPEN|wxFD_MULTIPLE);
|
||||
|
||||
dialog.Centre(wxCENTER_ON_SCREEN);
|
||||
|
||||
if (dialog.ShowModal() == wxID_OK)
|
||||
{
|
||||
wxArrayString paths, filenames;
|
||||
|
||||
@@ -218,7 +218,8 @@ class wxFileDialogMSWData
|
||||
public:
|
||||
explicit wxFileDialogMSWData(wxFileDialog* fileDialog)
|
||||
#if wxUSE_IFILEOPENDIALOG
|
||||
: m_fileDialog(fileDialog)
|
||||
: m_fileDialog(fileDialog),
|
||||
m_typeAlreadyChanged(false)
|
||||
#endif // wxUSE_IFILEOPENDIALOG
|
||||
{
|
||||
m_bMovedWindow = false;
|
||||
@@ -263,6 +264,24 @@ public:
|
||||
|
||||
wxSTDMETHODIMP OnTypeChange(IFileDialog* pfd) wxOVERRIDE
|
||||
{
|
||||
// There is no special notification for the dialog initialization, but
|
||||
// this function is always called when it's shown, so use it for
|
||||
// generating this notification as well.
|
||||
if ( !m_typeAlreadyChanged )
|
||||
{
|
||||
m_typeAlreadyChanged = true;
|
||||
|
||||
wxCOMPtr<IOleWindow> window;
|
||||
HRESULT hr = pfd->QueryInterface(wxIID_PPV_ARGS(IOleWindow, &window));
|
||||
if ( SUCCEEDED(hr) )
|
||||
{
|
||||
HWND hwnd;
|
||||
hr = window->GetWindow(&hwnd);
|
||||
if ( SUCCEEDED(hr) )
|
||||
m_fileDialog->MSWOnInitDone(hwnd);
|
||||
}
|
||||
}
|
||||
|
||||
m_fileDialog->MSWOnTypeChange(FileDialogGetFileTypeIndex(pfd));
|
||||
|
||||
return S_OK;
|
||||
@@ -273,6 +292,8 @@ public:
|
||||
|
||||
wxFileDialog* const m_fileDialog;
|
||||
|
||||
bool m_typeAlreadyChanged;
|
||||
|
||||
DECLARE_IUNKNOWN_METHODS;
|
||||
#endif // wxUSE_IFILEOPENDIALOG
|
||||
|
||||
@@ -582,11 +603,11 @@ int wxFileDialog::ShowModal()
|
||||
|
||||
/*
|
||||
We need to use the old style dialog in order to use a hook function
|
||||
which allows us to position it or use custom controls in it but, if
|
||||
possible, we prefer to use the new style one instead.
|
||||
which allows us to use custom controls in it but, if possible, we
|
||||
prefer to use the new style one instead.
|
||||
*/
|
||||
#if wxUSE_IFILEOPENDIALOG
|
||||
if ( (!m_data || !m_data->m_bMovedWindow) && !HasExtraControlCreator() )
|
||||
if ( !HasExtraControlCreator() )
|
||||
{
|
||||
const int rc = ShowIFileDialog(hWndParent);
|
||||
if ( rc != wxID_NONE )
|
||||
|
||||
Reference in New Issue
Block a user