From 551a706062bf1f2adf66a446cb14b2666d54af01 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Thu, 8 Jun 2000 12:06:08 +0000 Subject: [PATCH] Adjusts struct size if there's an error. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7545 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/filedlg.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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();