Discussion:
How to close view in MDI framework?
(too old to reply)
Rud1ger Sch1erz
2006-11-02 20:35:40 UTC
Permalink
Hi,

I use DocTemplate to create multiple views of one document in a MDI
environment.

One of those views is of type CFormView.
class CBSatzFilterView : public CFormView

When the user makes a click on the ok-button in this form, I want to
close and destroy this certain view. I found out, how to use
CDocTemplates to let the framework create views, but not to
close/destroy views on demand.

My current solution is, to install a message-handler in my
CBSatzFilterView like this:

void CBSatzFilterView::OnBnClickedOk()
{
// Do some changes to the document and then:

GetDocument()->UpdateAllViews(this);
GetDocument()->RemoveView(this);
((CChildFrame*)GetParentFrame())->OnClose();
}

This seems to work.

My question is: Is there a more MDI-framework-like way to this? Have I
overlooked something?

Cheers from Germany,
Rudiger
Ajay Kalra
2006-11-03 03:36:15 UTC
Permalink
A simpler way would be:

void CBSatzFilterView::OnBnClickedOk()
{
ASSERT_VALID(GetParentFrame());
GetParentFrame()->PostMessage(WM_CLOSE);
}
--
Ajay Kalra [MVP - VC++]
***@yahoo.com
Rud1ger Sch1erz
2006-11-06 10:25:33 UTC
Permalink
Post by Rud1ger Sch1erz
void CBSatzFilterView::OnBnClickedOk()
{
ASSERT_VALID(GetParentFrame());
GetParentFrame()->PostMessage(WM_CLOSE);
}
Thank you very much.

Cheers,
Rudiger

Loading...