I want to set CFileDialog default path so when user click a button that will
do the dialog, the default path will be the one I set.
I have read the MSDN Library and there was only GetPathName. No SetPathName.
CFileDialog dlg( TRUE, NULL, NULL, OFN_FILEMUSTEXIST, "All Files
(*.*)|*.*||" );
if( dlg.DoModal() == IDOK ){
}
How to set the path?
Thank you very much.
Before you call DoModal(), you can set the initial directory by setting the
dialog object's m_ofn.lpstrInitialDir member.
See the current docs for the OPENFILENAME structure for changes in behavior
on Vista.
Mark
--
Mark Salsbery
Microsoft MVP - Visual C++
>
> Thank you very much.
> I want to set CFileDialog default path so when user click a button that
> will
> do the dialog, the default path will be the one I set.
>
> I have read the MSDN Library and there was only GetPathName. No
> SetPathName.
>
> CFileDialog dlg( TRUE, NULL, NULL, OFN_FILEMUSTEXIST, "All Files
> (*.*)|*.*||" );
CFileDialog is a wrapper on Win32 Platform SDK structure OPENFILENAME.
"OPENFILENAME"
http://msdn.microsoft.com/en-us/library/ms646839(VS.85).aspx
You may be interested in the 'lpstrInitialDir' field of that structure.
To access OPENFILENAME structure embedded in CFileDialog, you can use
CFileDialog::GetOFN() method.
Giovanni