|
Except forlgq1982, the rest are a bunch of rice buckets, super rice buckets.
Tell beginners: how to design MDI programs with VC.
1. First create a multi-document program;
2. Click [Insert], [New Form...] menu item.
Enter CTemp1View in Name
Base Class select CFormView
Do not move the others, click the "OK" button.
3. Click [Insert], [New Class...] menu item.
Name: CTempFrm
Base class: CMDIChildWnd
Click the "OK" button.
4. Add in CXXXApp
public:
CMultiDocTemplate * m_pTemplate;
5. In CXXXApp, modify the code of InitInstance().
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; //comment out
//pDocTemplate = new CMultiDocTemplate( //comment out
//Add your own MDI child form
m_pTemplate = new CMultiDocTemplate(
IDR_XXXTYPE, // unchanged here
RUNTIME_CLASS(CXXXDoc), // unchanged here
RUNTIME_CLASS(CTempFrm), // need to be modified
RUNTIME_CLASS(CTempView));//Need to modify
AddDocTemplate(m_pTemplate);
//If there are other forms
m_pTemplate2 = new CMultiDocTemplate(
IDR_XXXTYPE, // unchanged here
RUNTIME_CLASS(CXXXDoc), // unchanged here
RUNTIME_CLASS(CTemp2Frm), // need to be modified
RUNTIME_CLASS(CTemp2View));//Need to modify
AddDocTemplate(m_pTemplate2);
m_pTemplate3 = new CMultiDocTemplate(
IDR_XXXTYPE, // unchanged here
RUNTIME_CLASS(CXXXDoc), // unchanged here
RUNTIME_CLASS(CTemp3Frm), // need to be modified
RUNTIME_CLASS(CTemp3View));//Need to modify
AddDocTemplate(m_pTemplate3);
...
// create main MDI Frame window
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
m_pMainWnd = pMainFrame;
5. Call the subform
Declare variable
protected:
CTempFrm* m_pTempFrm;
void CMainFrame::OnMenu1Click()
{
// Open an existing frame window
if(pTempFrm)
MDIActivate (pTempFrm);
else
{
//The window is not opened, reopen a new window
CDocument *pDoc=((CFXXXApp *)AfxGetApp())->m_pTemplate->OpenDocumentFile(NULL);
pDoc->SetTitle("Exceptlgq1982on the upper floor of subform 1, all the rest are a group of rice buckets, super rice buckets.");
//Save and newly opened frame window pointer
m_pTempFrm= (CTempFrm*)MDIGetActive();
}
}
and also! ! ! ! Suitable for beginners |
|