C
CheezWhines
Guest
I can't seem to figure out why this isn't working. I tried comparing a SDI made by default to my project. I created my project using blank project. Whenever OpenDocumentFile or CreateDocumentFile is used it just opens a message box saying "Failed to create new document". Here is my App;
BEGIN_MESSAGE_MAP(BaseApp, CWinApp)
ON_COMMAND(ID_FILE_NEW, &CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, &CWinApp::OnFileOpen)
END_MESSAGE_MAP()
BaseApp::BaseApp() {
SetAppID(_T("TextEditor"));
}
BaseApp::~BaseApp()
{
}
BaseApp theApp;
BOOL BaseApp::InitInstance() {
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinApp::InitInstance();
SetRegistryKey(_T("TextEditor"));
LoadStdProfileSettings(5);
m_pRecentFileList->ReadList();
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(BaseDocument),
RUNTIME_CLASS(BaseFrame),
RUNTIME_CLASS(BaseView));
if (!pDocTemplate)
return FALSE;
AddDocTemplate(pDocTemplate);
BeginningDlg newDlg;
BOOL newdoc = TRUE;
for (auto i = 0; i <= 4; i++) {
newDlg.rf.Add(m_pRecentFileList->operator[](i));
}
switch (newDlg.DoModal()) {
case 1:
newdoc = FALSE;
break;
case 3:
break;
default:
return FALSE;
}
if (newdoc) {
auto doc = dynamic_cast<BaseDocument*>(pDocTemplate->CreateNewDocument());
}
else {
auto doc = dynamic_cast<BaseDocument*>(pDocTemplate->OpenDocumentFile(newDlg.currPath));
}
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
AfxInitRichEdit2();
EnableShellOpen();
RegisterShellFileTypes(TRUE);
if (!ProcessShellCommand(cmdInfo))
return FALSE;
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
return TRUE;
}
Continue reading...
BEGIN_MESSAGE_MAP(BaseApp, CWinApp)
ON_COMMAND(ID_FILE_NEW, &CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, &CWinApp::OnFileOpen)
END_MESSAGE_MAP()
BaseApp::BaseApp() {
SetAppID(_T("TextEditor"));
}
BaseApp::~BaseApp()
{
}
BaseApp theApp;
BOOL BaseApp::InitInstance() {
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinApp::InitInstance();
SetRegistryKey(_T("TextEditor"));
LoadStdProfileSettings(5);
m_pRecentFileList->ReadList();
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(BaseDocument),
RUNTIME_CLASS(BaseFrame),
RUNTIME_CLASS(BaseView));
if (!pDocTemplate)
return FALSE;
AddDocTemplate(pDocTemplate);
BeginningDlg newDlg;
BOOL newdoc = TRUE;
for (auto i = 0; i <= 4; i++) {
newDlg.rf.Add(m_pRecentFileList->operator[](i));
}
switch (newDlg.DoModal()) {
case 1:
newdoc = FALSE;
break;
case 3:
break;
default:
return FALSE;
}
if (newdoc) {
auto doc = dynamic_cast<BaseDocument*>(pDocTemplate->CreateNewDocument());
}
else {
auto doc = dynamic_cast<BaseDocument*>(pDocTemplate->OpenDocumentFile(newDlg.currPath));
}
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
AfxInitRichEdit2();
EnableShellOpen();
RegisterShellFileTypes(TRUE);
if (!ProcessShellCommand(cmdInfo))
return FALSE;
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
return TRUE;
}
Continue reading...