A:
Another solution is to derive from CDocManager and override CDocManager::DoPromptFileName.
In the overridden DoPromptFileName, we can either write our own implementation or modify some parameters then call the base class method.
Finally, in InitInstance of application, replace the call to AddDocTemplate as shown below.
Next example changes the default dialog title and shows "Help" button.
Code:
class CCustomDocManager : public CDocManager
{
public:
virtual BOOL DoPromptFileName(CString& fileName, UINT nIDSTitle,
DWORD lFlags, BOOL bOpenFileDialog, CDocTemplate* pTemplate);
};
Code:
BOOL CCustomDocManager::DoPromptFileName(CString& fileName, UINT nIDSTitle,
DWORD lFlags, BOOL bOpenFileDialog, CDocTemplate* pTemplate)
{
// set the custom title
nIDSTitle = bOpenFileDialog ? IDS_CUSTOM_OPEN_TITLE : IDS_CUSTOM_SAVEAS_TITLE;
// add "show Help button" flag
lFlags |= OFN_SHOWHELP;
// call the base class function
return CDocManager::DoPromptFileName(fileName, nIDSTitle,
lFlags, bOpenFileDialog, pTemplate);
}
Code:
BOOL CMyApp::InitInstance()
{
// ...
// AddDocTemplate(pDocTemplate); // <-- replace this
if (m_pDocManager == NULL)
{
m_pDocManager = new CCustomDocManager;
}
m_pDocManager->AddDocTemplate(pDocTemplate);
// ...
Bookmarks