1。请部各位,在多文档的程序中,我一下做了20个文档模板,可不可以,如不可以,为什么?
2。如可以,怎么做才可以在程序一开始的时候,不出现选择文档模板的对话框,而是直接打开其中一个文档呢?
3。在程序运行中,如何用代码打开每个不同的模板呢?急用啊!给出代码!立刻送分!!!
2。如可以,怎么做才可以在程序一开始的时候,不出现选择文档模板的对话框,而是直接打开其中一个文档呢?
3。在程序运行中,如何用代码打开每个不同的模板呢?急用啊!给出代码!立刻送分!!!
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo); // Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
这段代码注销掉,向打开哪个模板按问题3处理;
问题3:给个例子,你在改改:
CWnd* pWnd;
CString str; CMDIFrameWnd* pMainWnd=(CMDIFrameWnd*)m_pMainWnd;
CWnd* pFirstWnd=pMainWnd->MDIGetActive();
pWnd=NULL;
//先检测是否已经打开,如果已经打开,推到最前面
while(pFirstWnd && pWnd!=pFirstWnd)
{
pWnd=pMainWnd->MDIGetActive();
pWnd->GetWindowText(str);
if (str=="××××××")
{
return;
}
pMainWnd->MDINext();
pWnd=pMainWnd->MDIGetActive();
} //打开模板 (m_pCircuitWasteTemplate是你要打开的文档模板)
CDocument* pDoc=m_pCircuitWasteTemplate->OpenDocumentFile(NULL);
pDoc->SetTitle("×××××");
pWnd = ((CMDIFrameWnd*)m_pMainWnd)->MDIGetActive();
pWnd->SetWindowText("××××××");
pWnd->ShowWindow(SW_SHOWMAXIMIZED);//子窗口最大化显示
然后进行初始化模板:例如建立两个模板,一个文档模板,一个弹球模板,当然还可以照此继续建下去。
BOOL CMDIApp::InitInstance()
{
AfxEnableControlContainer(); // Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif // Change the registry key under which our settings are stored.
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("Local AppWizard-Generated Applications")); LoadStdProfileSettings(); // Load standard INI file options (including MRU) // Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
//×¢²áÓ¦ÓóÌÐòµÄÎĵµÄ£°å£¬ÎĵµÄ£°åÓÃÀ´Á¬½ÓÎĵµ£¬¿ò¼Ü´°¿ÚºÍÊÓͼ
CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(
IDR_HELLOTYPE,
RUNTIME_CLASS(CHelloDoc),
RUNTIME_CLASS(CHelloFrame), // custom MDI child frame
RUNTIME_CLASS(CHelloView));
AddDocTemplate(pDocTemplate); //ÔÚÎĵµÄ£°åÁбíÖÐÔö¼Óµ¯Çò(Bounce)Ä£°å¡£ CMultiDocTemplate* pBounceTemplate;
pBounceTemplate = new CMultiDocTemplate(
IDR_BOUNCETYPE,
RUNTIME_CLASS(CBounceDoc),
RUNTIME_CLASS(CBounceFrame), // custom MDI child frame
RUNTIME_CLASS(CBounceView));
AddDocTemplate(pBounceTemplate); // create main MDI Frame window
//´´½¨Ö÷MDI¿ò¼Ü´°¿Ú¡£
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
m_pMainWnd = pMainFrame; // Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo); // Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE; // The main window has been initialized, so show and update it.
//ÏÔʾ²¢Ë¢ÐÂÖ÷´°¿Ú¡£
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow(); return TRUE;
}
然后注意修改RESOURCE中的STRING TABLE列表中的相应字符串的信息,不懂的查书。
或者该网站也可以,上面有相关介绍。