Click to See Complete Forum and Search --> : path preselection for the dialog 'Save as'-dialog


M. Flamensbeck
August 13th, 1999, 06:19 AM
In a SDI-application I want to determine the intitial path of the 'Save as'-dialog, which is called when I click on 'File-Save as'.
This should be possible with the OnSaveDocument-function.However, this function is only called when I click on 'File-Save' and the file's name is already determined.
What can I do?

Michael Flamensbeck

Solai Palani
August 13th, 1999, 08:55 AM
Hi,
To Get the Path of the "Save As " Dlg , do the following

CFileDialog FileDlg(FALSE,..............)// Use other required parameters
FileDlg.DOModal();//Call the "Save As" Dlg
CString Path_Save_As = FileDlg.GetPathName(); //To get the PAth name
MessageBox(Path_Save_As);//To pop-up path name

I hope this info will help you.
For Further discussion,Pl mail me back.

With Smile,
Palani

Rail Jon Rogut
August 13th, 1999, 01:42 PM
CString szTemp = "default.edl";

CFileDialog dlg(FALSE, _T("edl"), szTemp,
OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_NOCHANGEDIR,
_T("SAWPLUS EDL Files (*.edl)|*.edl||"));

szTemp = "X:\\Starting\\Path\\";

dlg.m_ofn.lpstrInitialDir = (LPCTSTR)szTemp; // Set the start folder

if (dlg.DoModal() != IDOK)
{
return; // Cancel out.
}


Rail

Recording Engineer/Software Developer
Rail Jon Rogut Software
railro@earthlink.net
http://home.earthlink.net/~railro/

Rail Jon Rogut
August 13th, 1999, 01:57 PM
Possibly I misunderstood your question... what you need to do is derive your own class from CFileDialog and look at OnFolderChange() which will be called every time the folder is changed... By setting a BOOLean value to FALSE in the constructor, you can check for zero in OnFolderChange() and after it's been called once, set the BOOLean value to TRUE.

Rail

Recording Engineer/Software Developer
Rail Jon Rogut Software
railro@earthlink.net
http://home.earthlink.net/~railro/

M. Flamensbeck
August 19th, 1999, 08:11 AM
Hi,
thank's for answer, but it hits not my problem,
because the CFileDialog, which is called after I click the menu File-Save As... is not an object of my own code but part of the doc-view architecture.

M. Flamensbeck

Rail Jon Rogut
August 19th, 1999, 01:55 PM
Well I don't think that my answer deserves a negative score point! If I'd given you a completely wrong answer I could understand that, but actually the answer I gave indicates what you have to do... You have to override the function in your Doc class where the Common Dialog is displayed [Add your own handler for OnFileSaveAs()] and derive your own class from CFileDialog where you handle the message OnFileNameOK(). That's the only way that you'll be able to get the value before the dialog is returned from DoModal().

You can see an example of subclassing CFileDialog on my web site at http://home.earthlink.net/~railro/mfc_link.html.

Rail

------------
Recording Engineer/Software Developer
Rail Jon Rogut Software
http://home.earthlink.net/~railro/
railro@earthlink.net

M. Flamensbeck
August 20th, 1999, 05:11 AM
Sorry, I was really wrong with the negative score point. Your code with the additional line "CDocument::OnSaveDocument(dlg.GetPathName())"
in the OnFileSaveAs() handler of Doc class solves my problem. Thank you.

I would like change my rating in "Useful/Answer the question", but I don't know how!

M. Flamensbeck