+
+ m_path = pidl.GetPath();
+
+ // change current working directory if asked so
+ if (HasFlag(wxDD_CHANGE_DIR))
+ wxSetWorkingDirectory(m_path);
+
+ return m_path.empty() ? wxID_CANCEL : wxID_OK;
+}
+
+// ----------------------------------------------------------------------------
+// private functions
+// ----------------------------------------------------------------------------
+
+static int CALLBACK
+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
+ ::SendMessage(hwnd, BFFM_SETSELECTION, TRUE, pData);
+ break;
+#endif // BFFM_SETSELECTION
+
+
+ case BFFM_SELCHANGED:
+ // note that this doesn't work with the new style UI (MSDN doesn't
+ // say anything about it, but the comments in shlobj.h do!) but we
+ // still execute this code in case it starts working again with the
+ // "new new UI" (or would it be "NewUIEx" according to tradition?)
+ {
+ // Set the status window to the currently selected path.
+ wxString strDir;
+ if ( SHGetPathFromIDList((LPITEMIDLIST)lp,
+ wxStringBuffer(strDir, MAX_PATH)) )
+ {
+ // NB: this shouldn't be necessary with the new style box
+ // (which is resizable), but as for now it doesn't work
+ // anyhow (see the comment above) no harm in doing it
+
+ // need to truncate or it displays incorrectly
+ static const size_t maxChars = 37;
+ if ( strDir.length() > maxChars )
+ {
+ strDir = strDir.Right(maxChars);
+ strDir = wxString(wxT("...")) + strDir;
+ }
+
+ SendMessage(hwnd, BFFM_SETSTATUSTEXT,
+ 0, (LPARAM)strDir.wx_str());
+ }
+ }
+ break;
+
+ //case BFFM_VALIDATEFAILED: -- might be used to provide custom message
+ // if the user types in invalid dir name
+ }
+
+ return 0;