X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2bda0e173844e8e0f8acf4e8ad8b5c26e5c6fe5d..ea9a4296a23fa5b1441e9d3abca357fe7cb412b5:/src/msw/dirdlg.cpp diff --git a/src/msw/dirdlg.cpp b/src/msw/dirdlg.cpp index ecfac092c5..32505241db 100644 --- a/src/msw/dirdlg.cpp +++ b/src/msw/dirdlg.cpp @@ -46,6 +46,34 @@ IMPLEMENT_CLASS(wxDirDialog, wxDialog) #endif +static int CALLBACK +BrowseCallbackProc(HWND hwnd,UINT uMsg,LPARAM lp, LPARAM pData) + { + TCHAR szDir[MAX_PATH]; + + switch(uMsg) + { + case BFFM_INITIALIZED: + // We have put m_path into pData. + // TRUE -> passing char *, not dir id. + SendMessage(hwnd,BFFM_SETSELECTION,TRUE,pData); + break; + + case BFFM_SELCHANGED: + // Set the status window to the currently selected path. + if (SHGetPathFromIDList((LPITEMIDLIST) lp ,szDir)) + { + SendMessage(hwnd,BFFM_SETSTATUSTEXT,0,(LPARAM)szDir); + } + break; + + default: + break; + } + return 0; + } + + wxDirDialog::wxDirDialog(wxWindow *parent, const wxString& message, // const wxString& caption, const wxString& defaultPath, @@ -66,7 +94,7 @@ int wxDirDialog::ShowModal(void) if (m_parent) hWnd = (HWND) m_parent->GetHWND(); BROWSEINFO bi; - LPSTR lpBuffer; + LPTSTR lpBuffer; // LPITEMIDLIST pidlPrograms; // PIDL for Programs folder LPITEMIDLIST pidlBrowse; // PIDL selected by user LPMALLOC pMalloc = NULL; @@ -77,7 +105,7 @@ int wxDirDialog::ShowModal(void) return wxID_CANCEL; // Allocate a buffer to receive browse information. - if ((lpBuffer = (LPSTR) pMalloc->Alloc(MAX_PATH)) == NULL) + if ((lpBuffer = (LPTSTR) pMalloc->Alloc(MAX_PATH)) == NULL) { pMalloc->Release(); return wxID_CANCEL; @@ -97,10 +125,10 @@ int wxDirDialog::ShowModal(void) bi.hwndOwner = hWnd; bi.pidlRoot = NULL; // pidlPrograms; bi.pszDisplayName = lpBuffer; - bi.lpszTitle = (LPCTSTR) (const char *) m_message; + bi.lpszTitle = m_message; // BC++ 4.52 says LPSTR, not LPTSTR? bi.ulFlags = 0; - bi.lpfn = NULL; - bi.lParam = 0; + bi.lpfn = BrowseCallbackProc; + bi.lParam = (LPARAM)m_path.c_str(); // Browse for a folder and return its PIDL. pidlBrowse = SHBrowseForFolder(&bi);