]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/dirdlg.cpp
Added support for item clicks
[wxWidgets.git] / src / msw / dirdlg.cpp
index 3c20ff18199d9508503126618b11e6c8109d9ee6..5434b5d0d7a0c2ecc7564b5e38bc7021874d2c27 100644 (file)
@@ -28,7 +28,7 @@
 #include "wx/dirdlg.h"
 #endif
 
-#if defined(__WIN95__) && !defined(__GNUWIN32__)
+#if (defined(__WIN95__) && !defined(__GNUWIN32__))||defined(wxUSE_NORLANDER_HEADERS)
 #include "shlobj.h" // Win95 shell
 #endif
 
 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,
@@ -61,7 +89,7 @@ wxDirDialog::wxDirDialog(wxWindow *parent, const wxString& message,
 int wxDirDialog::ShowModal(void)
 {
     // Unfortunately Gnu-Win32 doesn't yet have COM support
-#if defined(__WIN95__) && !defined(__GNUWIN32__)
+#if (defined(__WIN95__) && !defined(__GNUWIN32__))||defined(wxUSE_NORLANDER_HEADERS)
   HWND hWnd = 0;
   if (m_parent) hWnd = (HWND) m_parent->GetHWND();
 
@@ -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;
@@ -99,8 +127,8 @@ int wxDirDialog::ShowModal(void)
     bi.pszDisplayName = lpBuffer; 
     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);