Print Page | Close Window

Proper Destruction Method for Dock Panes

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Docking Pane
Forum Description: Topics Related to Codejock Docking Pane
URL: http://forum.codejock.com/forum_posts.asp?TID=2171
Printed Date: 05 May 2024 at 7:05pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Proper Destruction Method for Dock Panes
Posted By: umcbrad
Subject: Proper Destruction Method for Dock Panes
Date 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.




Replies:
Posted By: Ark42
Date 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;
}




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net