From: Psychoboy on
I have a CMDIFrameWndEx which I am handling OnCloseMiniFrame.

What I am doing now is doing:

CBasePane* pPane = dynamic_cast<CBasePane*>(pWnd->GetPane());
while(pPane != NULL)
{
pWnd->RemovePane(pPane);
pPane->DestroyWindow();
pPane = dynamic_cast<CBasePane*>(pWnd->GetPane());
}

to destroy all the panes within it when closed. I am dynamically
creating these panes. I want these panes gone when the Miniframe is
closed. This seems to work but I am worried this is not the proper way
to do it since GetPane() returns a CWnd* instead, thats why I am doing
the dynamic_cast. Is there a better way to iterate through all the
panes to destroy them?

Thanks.
From: AliR on
It really doesn't make a difference what GetPane returns, it is still a
pointer to your object that inherits from CWnd in one way or another. That
is what dynamic_cast is for.

So what you are doing works fine.

Are you deleting the object somewhere? I don't see a call to delete.

AliR.


"Psychoboy" <psycoboy(a)gmail.com> wrote in message
news:d79ebdef-d0ce-4687-8d4f-7ab1b4c182d9(a)q4g2000yqm.googlegroups.com...
>I have a CMDIFrameWndEx which I am handling OnCloseMiniFrame.
>
> What I am doing now is doing:
>
> CBasePane* pPane = dynamic_cast<CBasePane*>(pWnd->GetPane());
> while(pPane != NULL)
> {
> pWnd->RemovePane(pPane);
> pPane->DestroyWindow();
> pPane = dynamic_cast<CBasePane*>(pWnd->GetPane());
> }
>
> to destroy all the panes within it when closed. I am dynamically
> creating these panes. I want these panes gone when the Miniframe is
> closed. This seems to work but I am worried this is not the proper way
> to do it since GetPane() returns a CWnd* instead, thats why I am doing
> the dynamic_cast. Is there a better way to iterate through all the
> panes to destroy them?
>
> Thanks.


From: Psychoboy on
It is deleting that is done in OnNcDestroy. I was just wondering if
there was a better way to iterate through the panes.

On Jan 5, 8:40 am, "AliR" <A...(a)online.nospam> wrote:
> It really doesn't make a difference what GetPane returns, it is still a
> pointer to your object that inherits from CWnd in one way or another.  That
> is what dynamic_cast is for.
>
> So what you are doing works fine.
>
> Are you deleting the object somewhere? I don't see a call to delete.
>
> AliR.
>
> "Psychoboy" <psyco...(a)gmail.com> wrote in message
>
> news:d79ebdef-d0ce-4687-8d4f-7ab1b4c182d9(a)q4g2000yqm.googlegroups.com...
>
>
>
> >I have a CMDIFrameWndEx which I am handling OnCloseMiniFrame.
>
> > What I am doing now is doing:
>
> > CBasePane* pPane = dynamic_cast<CBasePane*>(pWnd->GetPane());
> > while(pPane != NULL)
> > {
> > pWnd->RemovePane(pPane);
> > pPane->DestroyWindow();
> > pPane = dynamic_cast<CBasePane*>(pWnd->GetPane());
> > }
>
> > to destroy all the panes within it when closed. I am dynamically
> > creating these panes. I want these panes gone when the Miniframe is
> > closed. This seems to work but I am worried this is not the proper way
> > to do it since GetPane() returns a CWnd* instead, thats why I am doing
> > the dynamic_cast. Is there a better way to iterate through all the
> > panes to destroy them?
>
> > Thanks.