I need help!. I am trying to do something, which I consider to be simple, but I'm really struggling to get it to work.
I have an MDI application, working with just 1 document (for now).
I have several different classes of CView - FlamingoGanttView and FlamingoNavigatorView for example.
I have menu items to let the user add and remove these views.
Each view should appear only once.
At the moment, my MainFrame derives from CXTPMDIFrameWnd and contains a CXTPTabClientWnd m_MTIClientWnd and I keep a pointer to each view once it is create. This allows me to tick the menu item to say the view is on the screen.
At the moment, I have this code in the method behind the menu item.
void CMainFrame::OnViewsGanttChart()
{
if (m_viewGantt != NULL)
{
// Don't know how to close the window yet.
}
else
{
CMDIChildWnd* pActiveChild = MDIGetActive();
CDocument* pDocument= pActiveChild->GetActiveDocument()) == NULL)
CMultiDocTemplate docTemplate(IDR_GanttTYPE,
RUNTIME_CLASS(CFlamingoDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(FlamingoGanttView));
CChildFrame *newChild = (CChildFrame*) docTemplate.CreateNewFrame(pDocument, NULL);
docTemplate.InitialUpdateFrame(newChild, pDocument);
CCreateContext context;
context.m_pCurrentFrame = newChild;
context.m_pCurrentDoc = pDocument;
context.m_pNewViewClass = RUNTIME_CLASS(FlamingoGanttView);
context.m_pNewDocTemplate = &docTemplate;
m_viewGantt = (FlamingoGanttView*) CreateView(&context, IDGT_VIEW_GANTT);
SetActiveView(m_viewGantt, TRUE);
m_viewGantt->ShowWindow(SW_SHOW);
m_viewGantt->SetWindowText("Gantt Chart");
}
}
My first question is, does this sound like the best way to implement a tabbed main area?
Second question - how do I change the name of the tab - they are both getting called "Navigator1". I would like "Navigator" and "Gantt Chart" at the tab names.
Third question - how do I close these views and tabs? I have a pointer to the view, but CloseWindow and DestroyWindow don't do anything.