ChildFrames and views...
I use the ToolkitPro from CodeJock and I think I have been gradually digging
myself into a hole and now hitting problems!
I've used ToolkitPro to get Docking panes and MDI tabbed mainframe. All
looks very nice, but I have a problem when docking/undocking my views. Some
of my Views can be in a Pane or on a main tab. I need to keep the instance
of my view as it has selection information or some data that would otherwise
die with the instance, so I move it to a childframe window or a pane window.
Moving into a Pane is not a problem - I just create a new pane and attach
the view to that pane, then destroy the old childwindow, but going the other
way has caused me problems since day 1!
A typical view class is ViewRiskChart. When moving it into a pane all is
well, but when moving it back to a CChildFrame, my own pointer to the view
is left dangling (the view is destroyed) and the new view won't update as I
don't have a pointer to it and can't call specific numerical calculations to
calculate the points on the chart.
I might be wrong, but I think the problem is in the way I create CChildFrame
windows. I don't know how to create a CChildFrame window without a view
attached, so I have to create both, then attach my own view to the
childframe, set it active, then remove the undesired view, only I am
starting to get into problems now and I presume the following method is at
fault. I'm sure I have dug a hold here and can't see the obvious solution,
so can anyone shed any light on this for me. The method I use to create a
CChildFrame is:
// Generic method to create a new child frame - used by the above methods
CChildFrame* CMainFrame::createChildFrameWindow(CRuntimeClass *runtime)
{
CCircaDoc* pDocument = GetDocument();
CMultiDocTemplate docTemplate(IDR_GTVIEWTYPE,
RUNTIME_CLASS(CCircaDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
runtime);
CChildFrame *newChild = (CChildFrame*)
docTemplate.CreateNewFrame(pDocument, NULL);
docTemplate.InitialUpdateFrame(newChild, pDocument);
return newChild;
}