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.
|