// Author: Julian Smart
// Modified by:
// Created: 01/02/97
-// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/filename.h"
#include "wx/scopeguard.h"
#include "wx/tokenzr.h"
+#include "wx/modalhook.h"
// ----------------------------------------------------------------------------
// constants
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;
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
int wxFileDialog::ShowModal()
{
+ WX_HOOK_MODAL_DIALOG();
+
HWND hWnd = 0;
if (m_parent) hWnd = (HWND) m_parent->GetHWND();
if (!hWnd && wxTheApp->GetTopWindow())
of.lStructSize = gs_ofStructSize;
of.hwndOwner = hWnd;
- of.lpstrTitle = m_message.wx_str();
+ of.lpstrTitle = m_message.t_str();
of.lpstrFileTitle = titleBuffer;
of.nMaxFileTitle = wxMAXFILE + 1 + wxMAXEXT;
}
}
- of.lpstrFilter = (LPTSTR)filterBuffer.wx_str();
+ of.lpstrFilter = filterBuffer.t_str();
of.nFilterIndex = m_filterIndex + 1;
//=== Setting defaultFileName >>=========================================
wxString defextBuffer; // we need it to be alive until GetSaveFileName()!
if (HasFdFlag(wxFD_SAVE))
{
- const wxChar* extension = filterBuffer.wx_str();
+ const wxChar* extension = filterBuffer.t_str();
int maxFilter = (int)(of.nFilterIndex*2L) - 1;
for( int i = 0; i < maxFilter; i++ ) // get extension
(of.nFileExtension && fileNameBuffer[of.nFileExtension] == wxT('\0')) )
{
// User has typed a filename without an extension:
- const wxChar* extension = filterBuffer.wx_str();
+ const wxChar* extension = filterBuffer.t_str();
int maxFilter = (int)(of.nFilterIndex*2L) - 1;
for( int i = 0; i < maxFilter; i++ ) // get extension