Proper Destruction Method for Dock Panes |
Post Reply |
Author | |
umcbrad
Newbie Joined: 26 April 2005 Status: Offline Points: 10 |
Post Options
Thanks(0)
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. It may also be helpful to know that I am attempting to save and restore layouts. |
|
Ark42
Senior Member Joined: 20 October 2003 Status: Offline Points: 291 |
Post Options
Thanks(0)
|
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; } |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |