Re: How to embed a CFrameWnd-derived class into one of CSplitterWn
"Kamil Grabowski" <KamilGrabowski@discussions.microsoft.com> wrote in
message news:EAC2A100-B43E-4149-B2DD-B8352AF7E22B@microsoft.com...
Ok, I can use frame window as a splitter window right pane without
trouble.
But when I want to create it as a left pane, I get errors in OnClose().
Here's what I do:
I create a new MFC application project - SDI app with Windows Explorer
style
and no additional features except the control manifest. Next, I use Class
Wizard to derive a class from CFrameWnd (I call it CMyFrame, but that's
irrelevant). Then I change the default code for creating splitter window
panes with:
BOOL bRightOk, bLeftOk;
bRightOk = m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CMyFrame),
CSize(100, 100), pContext);
pContext->m_pNewViewClass = RUNTIME_CLASS(CMfcApp3View);
bLeftOk = m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CMyFrame),
CSize(100, 100), pContext);
I can't pinpoint the exact problem you are having, but here's what I do:
I DON'T use the context in the CreateView() calls - I pass NULL instead.
In the frame window classes, I override PreCreateWindow() as follows:
BOOL CMyFramePaneWnd::PreCreateWindow(CREATESTRUCT& cs)
{
CFrameWnd::PreCreateWindow(cs);
cs.style = (WS_CHILD | WS_VISIBLE);
cs.dwExStyle = 0;
return TRUE;
}
That's all the special code I use.
If you have frame windows with views being created through the doc/view
docmanager stuff, then that's a different thing that needs to be dealt with.
When using a frame as a splitter pane, the creation is different - the frame
window is created without a document initially.
Mark
--
Mark Salsbery
Microsoft MVP - Visual C++
I think the problem is that the view attached to the left pane frame
window
(CLeftView as created by the Wizard) is also attached via the document
template to the CMainFrame (also created by the wizard). Any suggestions
here? As I said, it fails on the OnClose() method.
"Mark Salsbery [MVP]" wrote: