Solved

SDI MFC CRichEditView File/Open Paths

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
difference between String.subString() and String.subSequence() 6 199
modThree challenge 4 90
FizzBuzz challenge 9 81
wordmultiple challenge 12 133
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: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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.

777 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