You're playing with the framework, instead of allowing it to do its job automatically. For example, here is your CWinAPP:OnInitInstance method:
Code:
BOOL CTestMDIApp::InitInstance()
{
AfxEnableControlContainer();
// Standard initialization
#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.
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
// Register document templates
m_pMultiDocTemplate = new CMultiDocTemplate(
IDR_TESTMDTYPE,
RUNTIME_CLASS(CTestMDIDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CTestMDIView));
AddDocTemplate(m_pMultiDocTemplate);
CMainFrame* pMainFrame = new CMainFrame;
m_glDocument=new CTestMDIDoc;
m_glDocument->SetTitle("Demo");
CCreateContext context;
context.m_pCurrentDoc=m_glDocument;
context.m_pNewViewClass=NULL;
context.m_pNewDocTemplate=m_pMultiDocTemplate;
context.m_pLastView=NULL;
context.m_pCurrentFrame=NULL;
if (!pMainFrame->LoadFrame(IDR_MAINFRAME,WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE,NULL, &context ))
return FALSE;
m_pMainWnd = pMainFrame;
OnViewView1();
// 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;
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();
return TRUE;
}
What are you trying to accomplish with this code that the framework doesn't do for you automatically? The framework has a document template manager that uses the CMultiDocTemplate object to create new documents and to link each of the views to the document. This happens automatically for you, in the sequence explained here: "Creating New Documents, Windows, and Views" at http://msdn.microsoft.com/library/en....and_Views.asp
Why are you trying to alter that automatic behavior?
The requiremnt is not splitter windows. but the two views should be in different childframe with the same document different views.
ya thats why i told use spiltter window.
in splitter window one document but u can create number of childframe using splitter window. i used the splitter window and got the 2 views in one document. if u want i will post the code.
ya now i got the point. u can use one more view for example firstview and second view both class contain same properties and same functions but u can access the views using GetActiveView() method try this method u will get the answer.
- MDI application
- which contains two diffrent child frame (not using splitter windows) with two different views which points to same document.
It is not a problem!
You should have two C<..>View derived classes for your views, the first view will be createad by framework automatically according to CMultiDocTemplate settings, the second view you could created from your own code. One of the possibles ways could be:
Send the message to main frame to create a new child window:
This will cause the CChildFrame::OnCreateClient() to be called. Inside the CChildFrame::OnCreateClient() you could use some flags pointing out which kind of a View must be created. To create a view the CFrameWnd::CreateView should be called.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.