Solved

SDI MFC CRichEditView File/Open Paths

Posted on 2002-05-11
2
333 Views
Last Modified: 2013-11-20
In my app when I go Save/Open the defualt path is My Documents.  How can I can it so if they went Open it would start at like c:\program files\.
0
Comment
Question by:MarkOttoSmith
2 Comments
 
LVL 12

Accepted Solution

by:
migel earned 200 total points
Comment Utility
Hi!
IMHO you have to derive your own class from CDocManager
and override
BOOL CDocManager::DoPromptFileName(CString& fileName, UINT nIDSTitle, DWORD lFlags, BOOL bOpenFileDialog, CDocTemplate* pTemplate)

BOOL CMyDocManager::DoPromptFileName(CString& fileName, UINT nIDSTitle, DWORD lFlags, BOOL bOpenFileDialog, CDocTemplate* pTemplate)
{
     CFileDialog dlgFile(bOpenFileDialog);

     CString title;
     VERIFY(title.LoadString(nIDSTitle));

     dlgFile.m_ofn.Flags |= lFlags;

     CString strFilter;
     CString strDefault;
     if (pTemplate != NULL)
     {
          ASSERT_VALID(pTemplate);
          _AfxAppendFilterSuffix(strFilter, dlgFile.m_ofn, pTemplate, &strDefault);
     }
     else
     {
          // do for all doc template
          POSITION pos = m_templateList.GetHeadPosition();
          BOOL bFirst = TRUE;
          while (pos != NULL)
          {
               CDocTemplate* pTemplate = (CDocTemplate*)m_templateList.GetNext(pos);
               _AfxAppendFilterSuffix(strFilter, dlgFile.m_ofn, pTemplate,
                    bFirst ? &strDefault : NULL);
               bFirst = FALSE;
          }
     }

     // append the "*.*" all files filter
     CString allFilter;
     VERIFY(allFilter.LoadString(AFX_IDS_ALLFILTER));
     strFilter += allFilter;
     strFilter += (TCHAR)'\0';   // next string please
     strFilter += _T("*.*");
     strFilter += (TCHAR)'\0';   // last string
     dlgFile.m_ofn.nMaxCustFilter++;

     dlgFile.m_ofn.lpstrFilter = strFilter;
     dlgFile.m_ofn.lpstrTitle = title;
     dlgFile.m_ofn.lpstrFile = fileName.GetBuffer(_MAX_PATH);

// changes!
//if fileName contains no path you have to set
      if (....)
         m_ofn.lpstrInitialDir = "c:\\Program files\\MyApp\\";

     int nResult = dlgFile.DoModal();
     fileName.ReleaseBuffer();
     return nResult == IDOK;
}

to use your own DocManager instead standart one yp have to add this lines in the your CWinApp derived class method InitApplication::
CMyApp::InitApplication()
{
   CDocManager::pStaticDocManage = new CMyDocManager;
}
0
 

Author Comment

by:MarkOttoSmith
Comment Utility
Thank You :)
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now