Solved

SDI MFC CRichEditView File/Open Paths

Posted on 2002-05-11
2
343 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
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.

696 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