]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/filedlg.cpp
Fix problem with COMDLG_FILTERSPEC declaration with MinGW-w64 4.8.
[wxWidgets.git] / src / msw / filedlg.cpp
index 27dfd888e5c4f4da3e17ee7bc5a3c78eca3f2da8..7327c7bdd71e632b68f2be02fd92dc38ded859c8 100644 (file)
@@ -4,7 +4,6 @@
 // Author:      Julian Smart
 // Modified by:
 // Created:     01/02/97
-// RCS-ID:      $Id$
 // Copyright:   (c) Julian Smart
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
@@ -47,7 +46,7 @@
 #include "wx/filename.h"
 #include "wx/scopeguard.h"
 #include "wx/tokenzr.h"
-#include "wx/testing.h"
+#include "wx/modalhook.h"
 
 // ----------------------------------------------------------------------------
 // constants
@@ -173,13 +172,23 @@ wxFileDialogHookFunction(HWND      hDlg,
 
         case WM_NOTIFY:
             {
-                OFNOTIFY *pNotifyCode = reinterpret_cast<OFNOTIFY *>(lParam);
-                if ( pNotifyCode->hdr.code == CDN_INITDONE )
+                OFNOTIFY* const
+                    pNotifyCode = reinterpret_cast<OFNOTIFY *>(lParam);
+                wxFileDialog* const
+                    dialog = reinterpret_cast<wxFileDialog *>(
+                                    pNotifyCode->lpOFN->lCustData
+                                );
+
+                switch ( pNotifyCode->hdr.code )
                 {
-                    reinterpret_cast<wxFileDialog *>(
-                                        pNotifyCode->lpOFN->lCustData)
-                        ->MSWOnInitDone((WXHWND)hDlg);
-                 }
+                    case CDN_INITDONE:
+                        dialog->MSWOnInitDone((WXHWND)hDlg);
+                        break;
+
+                    case CDN_SELCHANGE:
+                        dialog->MSWOnSelChange((WXHWND)hDlg);
+                        break;
+                }
             }
             break;
 
@@ -323,10 +332,29 @@ void wxFileDialog::MSWOnInitDone(WXHWND hDlg)
         SetPosition(gs_rectDialog.GetPosition());
     }
 
+    // Call selection change handler so that update handler will be
+    // called once with no selection.
+    MSWOnSelChange(hDlg);
+
     // we shouldn't destroy this HWND
     SetHWND(NULL);
 }
 
+void wxFileDialog::MSWOnSelChange(WXHWND hDlg)
+{
+    TCHAR buf[MAX_PATH];
+    LRESULT len = SendMessage(::GetParent(hDlg), CDM_GETFILEPATH,
+                              MAX_PATH, reinterpret_cast<LPARAM>(buf));
+
+    if ( len > 0 )
+        m_currentlySelectedFilename = buf;
+    else
+        m_currentlySelectedFilename.clear();
+
+    if ( m_extraControl )
+        m_extraControl->UpdateWindowUI(wxUPDATE_UI_RECURSE);
+}
+
 // helper used below in ShowCommFileDialog(): style is used to determine
 // whether to show the "Save file" dialog (if it contains wxFD_SAVE bit) or
 // "Open file" one; returns true on success or false on failure in which case
@@ -450,7 +478,7 @@ void wxFileDialog::MSWOnInitDialogHook(WXHWND hwnd)
 
 int wxFileDialog::ShowModal()
 {
-    WX_TESTING_SHOW_MODAL_HOOK();
+    WX_HOOK_MODAL_DIALOG();
 
     HWND hWnd = 0;
     if (m_parent) hWnd = (HWND) m_parent->GetHWND();