CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 1999
    Location
    Germany
    Posts
    3

    path preselection for the dialog 'Save as'-dialog

    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

  2. #2
    Join Date
    Aug 1999
    Posts
    2

    Re: path preselection for the dialog 'Save as'-dialog

    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


  3. #3
    Join Date
    May 1999
    Location
    CA, USA
    Posts
    586

    Re: path preselection for the dialog 'Save as'-dialog


    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
    [email protected]
    http://home.earthlink.net/~railro/

  4. #4
    Join Date
    May 1999
    Location
    CA, USA
    Posts
    586

    Re: path preselection for the dialog 'Save as'-dialog

    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
    [email protected]
    http://home.earthlink.net/~railro/

  5. #5
    Join Date
    Aug 1999
    Location
    Germany
    Posts
    3

    Re: path preselection for the dialog 'Save as'-dialog

    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


  6. #6
    Join Date
    May 1999
    Location
    CA, USA
    Posts
    586

    Re: path preselection for the dialog 'Save as'-dialog

    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/
    [email protected]

  7. #7
    Join Date
    Aug 1999
    Location
    Germany
    Posts
    3

    Re: path preselection for the dialog 'Save as'-dialog

    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




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured