Adding Splitter Windows Makes Mainframe Unable to Get Current Document

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Then I created a "Windows Explorer" style application. The wizard created OnCreateClient() in CMainFrame. But CFrameWnd::OnCreateClient() is not called this time. However, CFrameWnd::InitialUpdateFrame() successfully get a valid pWnd.

Sure it cannot be called! Just because you have overridden it!
Now tell us why did you do it? Didn't you read MSDN? You have to!

Remarks
Never call this function.The default implementation of this function creates a CView object from the information provided in pContext, if possible.
Override this function to override values passed in the CCreateContext object or to change the way controls in the main client area of the frame window are created. The CCreateContext members you can override are described in the CCreateContext class.

Since you do not call it and do NOT provide any other view creation no view is created at all!

Sure it cannot be called! Just because you have overridden it!
Now tell us why did you do it? Didn't you read MSDN? You have to!Since you do not call it and do NOT provide any other view creation no view is created at all!

No, you was not!
Since you provide your own view creation procedure (with a splitter window containing some panes) you do NOT need to call the base class OnCreateClient().
If you do not provide you own view creation procedure then you either have touse the the default procedure that is implemented in the CFrameWnd::OnCreateClient() or you won"t have any view window at all.
Note that if you do not provide you own view creation procedure you do not neet to override the OnCreateClient() either. In that case the default implementation will be called by the framework automatically.

When a "Windows Explorer" application is created, the SetActiveView() function is successfully called in CFrameWnd::InitialUpdateFrame(). While I create splitter windows, SetActiveView() in CFrameWnd::InitialUpdateFrame() is not called.

CFrameWnd::OnCreateClient() was not called in the application created by the wizard either. So why does pWnd = GetDescendantWindow(AFX_IDW_PANE_FIRST, TRUE) returns a non-NULL pointer?

Originally Posted by VictorN

No, you was not!
Since you provide your own view creation procedure (with a splitter window containing some panes) you do NOT need to call the base class OnCreateClient().
If you do not provide you own view creation procedure then you either have touse the the default procedure that is implemented in the CFrameWnd::OnCreateClient() or you won"t have any view window at all.
Note that if you do not provide you own view creation procedure you do not neet to override the OnCreateClient() either. In that case the default implementation will be called by the framework automatically.

When a "Windows Explorer" application is created, the SetActiveView() function is successfully called in CFrameWnd::InitialUpdateFrame(). While I create splitter windows, SetActiveView() in CFrameWnd::InitialUpdateFrame() is not called.

Debug your code to find out why it is not called!

Originally Posted by sunnysky

CFrameWnd::OnCreateClient() was not called in the application created by the wizard either. So why does pWnd = GetDescendantWindow(AFX_IDW_PANE_FIRST, TRUE) returns a non-NULL pointer?

It returns a non-NULL pointer just because the view with AFX_IDW_PANE_FIRST does exist!

When creating views in CMainFrame::OnCreateClient(), CView::OnCreate() is called for each view to be created. In CView::OnCreate(), the statement pContext->m_pCurrentDoc->AddView(this) will add a view and set its m_pDocument to be pContext->m_pCurrentDoc. pContext is set earlier indirectly by CWinApp::OnFileNew() and CWinApp::OnFileNew() was called by ProcessShellCommand(cmdInfo) in CTestApp::InitInstance().