Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Docking Pane
  New Posts New Posts RSS Feed - Proper Destruction Method for Dock Panes
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Proper Destruction Method for Dock Panes

 Post Reply Post Reply
Author
Message
umcbrad View Drop Down
Newbie
Newbie


Joined: 26 April 2005
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote umcbrad Quote  Post ReplyReply Direct Link To This Post Topic: Proper Destruction Method for Dock Panes
    Posted: 02 May 2005 at 11:08am

I was wondering if anyone out there knew the correct or recommended method for destroying panes?  The library does not seem to be very clear in this regard.  The problem I have posted may be a bug in my code, but I would like to address theoretical issue here as well.

Here is my scenario.

Docking Panes and their child windows are created dynamically.

I create a new pane by calling PaneManager::CreatePane().

I create a new CFrameWnd on the heap, then calling CFrameWnd::Create() and passing it a CRuntimeClass for the Doc and View.  I do this on a user action to create a new pane. 

Then I call CXTPDockingPane::Attach() in the OnDockingPane Notify() function.

Given this scenario, what is is the recommended method for removing and destroying a Docking Pane from the Manager and Docking Pane Layout List?

Keep in mind that I want to be able to dynamically create and destroy panes, and I want to destroy a pane and its associated child wnd when I close the pane.

Right now, I am trying to do this in response to the XTP_DPN_CLOSEPANE message.  (or possibly the XTP_DPN_ACTION::xtpPaneActionClosed message).  I try to call PaneManager::DestroyPane(), but I get a debug assertion failure,  the framework routes to the DockingPaneLayout::DestroyPane() function, and then at the end it calls the CCmdTarget::InternalRelease() function.  Here I where I get the failure, on this line:

 

DWORD CCmdTarget::InternalRelease()

{

ASSERT(GetInterfaceMap() != NULL);

...

I have tried simply getting pointers the stack and list of panes from the manager, and then manually removing them from the data structures.  This seems to work, however, I still have no easy way of destructing the pane, since it has a protected destructor.

 Do I have a bug, or am I not doing this correctly?

It may also be helpful to know that I am attempting to save and restore layouts.

Back to Top
Ark42 View Drop Down
Senior Member
Senior Member
Avatar

Joined: 20 October 2003
Status: Offline
Points: 291
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ark42 Quote  Post ReplyReply Direct Link To This Post Posted: 03 May 2005 at 2:33pm
This is what I use:

BOOL CMainFrame::DestroyPane(CXTPDockingPane *&pPane)
{
    if( pPane ) {
        pPane->Close();
        CWnd *pWnd = pPane->GetChild();
        if( pWnd ) {
            pWnd->DestroyWindow();
        }
        m_paneManager.DestroyPane(pPane);
        pPane = NULL;
        return TRUE;
    }
    return FALSE;
}

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.157 seconds.