+
+ return wxID_OK;
+}
+
+// ----------------------------------------------------------------------------
+// private functions
+// ----------------------------------------------------------------------------
+
+static int CALLBACK
+BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM pData)
+{
+ switch(uMsg)
+ {
+ 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;
+
+ case BFFM_SELCHANGED:
+ {
+ // Set the status window to the currently selected path.
+ TCHAR szDir[MAX_PATH];
+ if ( SHGetPathFromIDList((LPITEMIDLIST)lp, szDir) )
+ {
+ wxString strDir(szDir);
+ int maxChars = 40; // Have to truncate string else it displays incorrectly
+ if (strDir.Len() > (size_t) (maxChars - 3))
+ {
+ strDir = strDir.Right(maxChars - 3);
+ strDir = wxString(wxT("...")) + strDir;
+ }
+ SendMessage(hwnd, BFFM_SETSTATUSTEXT, 0, (LPARAM) (const wxChar*) strDir);
+ }
+ }
+ break;
+
+ //case BFFM_VALIDATEFAILED: -- might be used to provide custom message
+ // if the user types in invalid dir name
+ }
+
+ return 0;
+}
+
+
+static void ItemListFree(LPITEMIDLIST pidl)
+{
+ if ( pidl )
+ {
+ LPMALLOC pMalloc;
+ SHGetMalloc(&pMalloc);
+ if ( pMalloc )
+ {
+ pMalloc->Free(pidl);
+ pMalloc->Release();
+ }
+ else
+ {
+ wxLogLastError(wxT("SHGetMalloc"));
+ }
+ }