From e8615999ddf5e3ee218b11d1bdf031a565ca7539 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Wed, 14 Dec 2005 11:20:09 +0000 Subject: [PATCH] Fixed wxFileDialog breakage on WinCE due to incorrect structure size, and added correct error testing for WinCE. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36386 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + src/msw/filedlg.cpp | 31 ++++++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/docs/changes.txt b/docs/changes.txt index e2d1ba212a..4a48055676 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -61,6 +61,7 @@ wxWinCE: - All wxTopLevelWindows resizes accordingly to SIP visibility. - ::wxGetUserName() implemented. - wxDisplay enumeration support. +- Fixed wxFileDialog breakage on WinCE due to incorrect structure size. Unix: diff --git a/src/msw/filedlg.cpp b/src/msw/filedlg.cpp index 2bf5d527c3..c72e2d781f 100644 --- a/src/msw/filedlg.cpp +++ b/src/msw/filedlg.cpp @@ -276,7 +276,7 @@ int wxFileDialog::ShowModal() // comcdlg32.dll, but as we don't use the extended fields anyhow, set // the struct size to the old value - otherwise, the programs compiled // with new headers will not work with the old libraries -#if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0500) +#if !defined(__WXWINCE__) && defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0500) of.lStructSize = sizeof(OPENFILENAME) - (sizeof(void *) + 2*sizeof(DWORD)); #else // old headers @@ -396,6 +396,11 @@ int wxFileDialog::ShowModal() bool success = (m_dialogStyle & wxSAVE ? GetSaveFileName(&of) : GetOpenFileName(&of)) != 0; +#ifdef __WXWINCE__ + DWORD errCode = GetLastError(); +#else + DWORD errCode = CommDlgExtendedError(); + DWORD errCode = CommDlgExtendedError(); // GetOpenFileName will always change the current working directory on @@ -430,6 +435,7 @@ int wxFileDialog::ShowModal() } } #endif // __WIN32__ +#endif // __WXWINCE__ if ( success ) { @@ -503,6 +509,28 @@ int wxFileDialog::ShowModal() { // common dialog failed - why? #ifdef __WXDEBUG__ +#ifdef __WXWINCE__ + if (errCode == 0) + { + // OK, user cancelled the dialog + } + else if (errCode == ERROR_INVALID_PARAMETER) + { + wxLogError(wxT("Invalid parameter passed to file dialog function.")); + } + else if (errCode == ERROR_OUTOFMEMORY) + { + wxLogError(wxT("Out of memory when calling file dialog function.")); + } + else if (errCode == ERROR_CALL_NOT_IMPLEMENTED) + { + wxLogError(wxT("Call not implemented when calling file dialog function.")); + } + else + { + wxLogError(wxT("Unknown error %d when calling file dialog function."), errCode); + } +#else DWORD dwErr = CommDlgExtendedError(); if ( dwErr != 0 ) { @@ -511,6 +539,7 @@ int wxFileDialog::ShowModal() dwErr); } //else: it was just cancelled +#endif #endif } -- 2.45.2