Solved

SDI MFC CRichEditView File/Open Paths

Posted on 2002-05-11
2
341 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: 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

Suggested Solutions

Title # Comments Views Activity
countEvens challenge 2 111
sum67 challenge 35 107
Annoying "thing" blocks my view 4 113
how to use laptop or pad camera in vb.net windows application 2 85
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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 video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

790 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