Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to embed a CFrameWnd-derived class into one of CSplitterWnd pa

339 views
Skip to first unread message

Grabowski@discussions.microsoft.com Kamil Grabowski

unread,
Apr 3, 2008, 3:21:03 PM4/3/08
to
I would like to create something similar to Windows Explorer, where the pane
in a splitter window contains a dialog bar at the top. As only frame windows
support control bars, I was trying to make CSplitterWnd use a
CFrameWnd-derived class as one of the panes. It doesn't complain initially
and displays the frame window, but after closing the main window I get an
assertion when the framework calls EnsureParentFrame on my main frame window
in OnCloseDocument(). Do you have any ideas how to make this work?

Jonathan Wood

unread,
Apr 3, 2008, 6:02:30 PM4/3/08
to
To be honest, I think this approach is asking for problems. CFrameWnd has a
lot of higher-level functionality and will expect to be used a certain way.
Moreover, I'm not sure which dialog bar you are talking about--I'm not sure
I see a dialog bar within one of the panes for Windows Explorer.

I'd look at simply adding another user window within the pane. It might need
a little work to hook up any buttons but it sounds like an easier approach
to me than inserting a CFrameWnd. I just don't see that approach working
myself.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com


"Kamil Grabowski" <Kamil Grab...@discussions.microsoft.com> wrote in
message news:AAC40FF0-14C3-48CB...@microsoft.com...

Kamil Grabowski

unread,
Apr 3, 2008, 7:42:02 PM4/3/08
to
I'm not actually going to stick with the CFrameWnd solution, it was just the
first thing that came to my mind.

So what you are suggesting is to derive a class from CWnd, add support for
toolbars/dialog bars and embed a CView-derived class in it? Did I get it
straight?

Mark Salsbery [MVP]

unread,
Apr 3, 2008, 9:06:54 PM4/3/08
to
Actually any window can support a control bar - CFrameWnd just handles
layout we'd have to do ourselves :)

I use frame windows all the time as splitter window panes.

It seems you have a problem somewhere else - perhaps destroying a CFrameWnd
twice? Remember CFrameWnds delete themselves when they are destroyed - not
the same behavior as other windows/views.

How are you setting the frame window as a splitter pane?
I use CSplitterWnd::CreateView() and have n problems.

Mark

--
Mark Salsbery
Microsoft MVP - Visual C++

"Kamil Grabowski" <Kamil Grab...@discussions.microsoft.com> wrote in
message news:AAC40FF0-14C3-48CB...@microsoft.com...

Ajay Kalra

unread,
Apr 3, 2008, 10:56:45 PM4/3/08
to

"Mark Salsbery [MVP]" <MarkSalsbery[MVP]@newsgroup.nospam> wrote in message
news:9094A70A-C6CD-4937...@microsoft.com...

> Actually any window can support a control bar - CFrameWnd just handles
> layout we'd have to do ourselves :)

Thats not true. CControlBar derived classes assume CFrameWnd as the parent.
You can make it work, but you will need to do some extra work as shown in
DLGCBR32 example where a Dialog hosts a toolbar and a status bar.

> I use frame windows all the time as splitter window panes.

That is possible. CFrameWnd can be a child window as well.

---
Ajay

Mark Salsbery [MVP]

unread,
Apr 3, 2008, 11:23:09 PM4/3/08
to
"Ajay Kalra" <ajay...@yahoo.com> wrote in message
news:3AC78F24-6934-45CB...@microsoft.com...


Indeed! I have a LOT of them in my apps :)

Cheers,
Mark

--
Mark Salsbery
Microsoft MVP - Visual C++

>
> ---
> Ajay
>

Kamil Grabowski

unread,
Apr 4, 2008, 8:12:01 AM4/4/08
to
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 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]

unread,
Apr 4, 2008, 2:35:12 PM4/4/08
to
"Kamil Grabowski" <KamilGr...@discussions.microsoft.com> wrote in
message news:EAC2A100-B43E-4149...@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++

>

0 new messages