X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f07962f933088c85ae0776cd2e4aec4579d31ffa..4f433feff9251ded00bba26b633f93e660cd44c4:/src/msw/dirdlg.cpp?ds=sidebyside diff --git a/src/msw/dirdlg.cpp b/src/msw/dirdlg.cpp index 622e34b051..f011311407 100644 --- a/src/msw/dirdlg.cpp +++ b/src/msw/dirdlg.cpp @@ -28,7 +28,7 @@ #pragma hdrstop #endif -#if wxUSE_DIRDLG && !(defined(__SMARTPHONE__) && defined(__WXWINCE__)) +#if wxUSE_DIRDLG && (!defined(__WXWINCE__) || defined(__HANDHELDPC__)) #if defined(__WIN95__) && !defined(__GNUWIN32_OLD__) && wxUSE_OLE @@ -41,22 +41,12 @@ #endif #include "wx/msw/private.h" - -#ifdef __WXWINCE__ -#include -#include -#include -#endif -#include // Win95 shell +#include "wx/msw/wrapshl.h" // ---------------------------------------------------------------------------- // constants // ---------------------------------------------------------------------------- -#ifndef MAX_PATH - #define MAX_PATH 4096 // be generous -#endif - #ifndef BIF_NEWDIALOGSTYLE #define BIF_NEWDIALOGSTYLE 0x0040 #endif @@ -79,9 +69,6 @@ IMPLEMENT_CLASS(wxDirDialog, wxDialog) // private functions prototypes // ---------------------------------------------------------------------------- -// free the parameter -static void ItemListFree(LPITEMIDLIST pidl); - // the callback proc for the dir dlg static int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM pData); @@ -140,7 +127,13 @@ int wxDirDialog::ShowModal() bi.hwndOwner = parent ? GetHwndOf(parent) : NULL; bi.pidlRoot = NULL; bi.pszDisplayName = NULL; + // Please don't change this without checking it compiles + // with eVC++ first. +#if defined(__POCKETPC__) || defined(__SMARTPHONE__) + bi.lpszTitle = m_message.mb_str(); +#else bi.lpszTitle = m_message.c_str(); +#endif bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT; bi.lpfn = BrowseCallbackProc; bi.lParam = (LPARAM)m_path.c_str(); // param for the callback @@ -180,12 +173,9 @@ int wxDirDialog::ShowModal() } // do show the dialog - LPITEMIDLIST pidl = SHBrowseForFolder(&bi); + wxItemIdList pidl(SHBrowseForFolder(&bi)); - if ( bi.pidlRoot ) - { - ItemListFree((LPITEMIDLIST)bi.pidlRoot); - } + wxItemIdList::Free((LPITEMIDLIST)bi.pidlRoot); if ( !pidl ) { @@ -193,18 +183,9 @@ int wxDirDialog::ShowModal() return wxID_CANCEL; } - BOOL ok = SHGetPathFromIDList(pidl, wxStringBuffer(m_path, MAX_PATH)); + m_path = pidl.GetPath(); - ItemListFree(pidl); - - if ( !ok ) - { - wxLogLastError(wxT("SHGetPathFromIDList")); - - return wxID_CANCEL; - } - - return wxID_OK; + return m_path.empty() ? wxID_CANCEL : wxID_OK; } // ---------------------------------------------------------------------------- @@ -216,15 +197,16 @@ BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM pData) { switch(uMsg) { +#ifdef BFFM_SETSELECTION case BFFM_INITIALIZED: // sent immediately after initialisation and so we may set the // initial selection here // // wParam = TRUE => lParam is a string and not a PIDL -#ifndef __WXWINCE__ ::SendMessage(hwnd, BFFM_SETSELECTION, TRUE, pData); -#endif break; +#endif // BFFM_SETSELECTION + case BFFM_SELCHANGED: // note that this doesn't work with the new style UI (MSDN doesn't @@ -263,24 +245,6 @@ BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM pData) } -static void ItemListFree(LPITEMIDLIST pidl) -{ - if ( pidl ) - { - LPMALLOC pMalloc; - SHGetMalloc(&pMalloc); - if ( pMalloc ) - { - pMalloc->Free(pidl); - pMalloc->Release(); - } - else - { - wxLogLastError(wxT("SHGetMalloc")); - } - } -} - #else #include "../generic/dirdlgg.cpp" #endif // compiler/platform on which the code here compiles