In CMyAPP::InitInstacne () after m_pMainWnd->ShowWindow(),Add SendMessage(null,WM_COMMAND,ID_FILE_CLOSE,0);
解决方案 »
- 用vc2008的“windows 窗体应用程序”创建了个项目,在窗体的哪2个事件里写注册热键和注销热键?
- 怎么把工程变成英语?我建立时选择的是中文!
- 有关ComboBox的问题!很着急 谢谢
- 我的COM对象里定义了一个返回接口的属性,我想根据不同情况返回不同接口该怎么实现2
- 我的VC工程不小心把一.CPP文件给删了,几天的辛苦就没了
- 关于音频数据的处理问题?
- 急!为什么刻录的Audio CD,有的光驱读不出来啊?
- 各位老鸟,快来拔刀
- 急!急!TIMESTAMP_STRUCT怎样转换成CTime
- 如何自动添加ODBC?
- 谁能给我一个ISAPI中连接、打开数据库,并进行追加、删除、编辑记录的功能范例??100分!!!
- 各位高手,关于DEBUG问题,急,急!!!!
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
//新增加的代码
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
//增加完成
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
{
// TODO: Add your command handler code here
CCcccApp * pApp = (CCcccApp *)AfxGetApp();
CMultiDocTemplate * pDocTemplate = pApp->m_pCcccDocTemplate;//模板 CCcccDoc * pDocument = (CCcccDoc *)pDocTemplate->CreateNewDocument(); //产生编辑文档
if (pDocument == NULL)
{
TRACE0("CDocTemplate::CreateNewDocument returned NULL.\n");
AfxMessageBox(AFX_IDP_FAILED_TO_CREATE_DOC);
return ;
}
ASSERT_VALID(pDocument); BOOL bAutoDelete = pDocument->m_bAutoDelete;
pDocument->m_bAutoDelete = FALSE; // don't destroy if something goes wrong
CFrameWnd* pFrame = pDocTemplate->CreateNewFrame(pDocument, NULL);
pDocument->m_bAutoDelete = bAutoDelete;
if (pFrame == NULL)
{
AfxMessageBox(AFX_IDP_FAILED_TO_CREATE_DOC);
delete pDocument; // explicit delete on error
return ;
}
ASSERT_VALID(pFrame); BOOL bMakeVisible = TRUE; pDocTemplate->SetDefaultTitle(pDocument); // avoid creating temporary compound file when starting up invisible
if (!bMakeVisible)
pDocument->m_bEmbedded = TRUE; if (!pDocument->OnNewDocument())
{
// user has be alerted to what failed in OnNewDocument
TRACE0("CDocument::OnNewDocument returned FALSE.\n");
pFrame->DestroyWindow();
return ;
} // it worked, now bump untitled count
//pDocTemplate->m_nUntitledCount++; pDocTemplate->InitialUpdateFrame(pFrame, pDocument, bMakeVisible);
}
......
ParseCommandLine(cmdInfo);//MFC加的//{{你应插入的地方
if (cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew)
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
//}}你应插入的地方完if (!ProcessShellCommand(cmdInfo))//MFC加的
.....
建立文档后用指定的模版打开视图
比如:
BOOL CHmidesApp::InitInstance()
{
.................
pDocTemplate = new CMultiDocTemplate(
IDR_HMIDESTYPE,
RUNTIME_CLASS(CHmidesDoc),
RUNTIME_CLASS(CPicFrm), // custom MDI child frame
RUNTIME_CLASS(CPicView));
m_pPicDocTemplate=pDocTemplate;
....................
}void CHmidesDoc::OpenPicView(CPicObj *pPic)
{
POSITION posview;
CView *pView;
CPicView *pPicView;
posview=this->GetFirstViewPosition();
while(posview!=NULL)
{
pView=this->GetNextView(posview);
if(pView->IsKindOf(RUNTIME_CLASS(CPicView)))
{
pPicView=(CPicView *)pView;
if(pPicView->m_pPic==pPic)
{
((CPicFrm *)(pView->GetParent()))->ActivateFrame();
return;
}
}
} CPicFrm* pFrame = (CPicFrm*)((CHmidesApp *)AfxGetApp())->m_pPicDocTemplate->CreateNewFrame(this, NULL);
if (pFrame == NULL)
{
TRACE0("Warning: failed to create new frame.\n");
return; // command failed
}
pPicView=(CPicView *)pFrame->GetWindow(GW_CHILD);
pPicView->m_pPic=pPic;
pPicView->m_pCurLayer=pPic->m_Layer.GetHead();
((CHmidesApp *)AfxGetApp())->m_pPicDocTemplate->InitialUpdateFrame(pFrame, this);
}自己建立的模版不要加入到模版表,
退出视将模版删掉,免得内存遗留。