Solved

SDI MFC CRichEditView File/Open Paths

Posted on 2002-05-11
2
345 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 12

Accepted Solution

by:
migel earned 200 total points
ID: 7003219
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
ID: 7003275
Thank You :)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

734 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