diff --git a/src/msw/filedlg.cpp b/src/msw/filedlg.cpp index bdbc6afbcd..ffa1f75955 100644 --- a/src/msw/filedlg.cpp +++ b/src/msw/filedlg.cpp @@ -326,6 +326,26 @@ int wxFileDialog::ShowModal() bool success = (m_dialogStyle & wxSAVE) ? (GetSaveFileName(&of) != 0) : (GetOpenFileName(&of) != 0); + DWORD errCode = CommDlgExtendedError(); + + if (!success && (errCode == CDERR_STRUCTSIZE)) + { + // The struct size has changed so try a smaller or bigger size + + int oldStructSize = of.lStructSize; + of.lStructSize = oldStructSize - (sizeof(void *) + 2*sizeof(DWORD)); + success = (m_dialogStyle & wxSAVE) ? (GetSaveFileName(&of) != 0) + : (GetOpenFileName(&of) != 0); + errCode = CommDlgExtendedError(); + + if (!success && (errCode == CDERR_STRUCTSIZE)) + { + of.lStructSize = oldStructSize + (sizeof(void *) + 2*sizeof(DWORD)); + success = (m_dialogStyle & wxSAVE) ? (GetSaveFileName(&of) != 0) + : (GetOpenFileName(&of) != 0); + } + } + if ( success ) { m_fileNames.Empty();