CFormView parented by a CTabCtrl
Posted on 1997-06-04
I am attempting to create a CTabCtrl and associate a CFormView with each tab to display various statistics. So far it all works fine, I can launch the app, which creates a CView view, the CView view then creates a CTabctrl control and the control creates each of the associated CFormViews by creating a "CreateContext" object and calling thier "Create" member functions.
I have commented out the creation of all but one tab and its associated CFormView. (just to make debugging easier)
I do not currently make any DestoryWindow() calls, but I have verified that the framework does call the DestroyWindow functions and destructors correctly. The problem occurs just after the destructor for the first CFormView is called.
The problem is that when I exit the application I get an ASSERTION FAILED message stating that _BLOCK_TYPE_IS_INVALID(pHead->nBlockUse) which occurs in dbgheap.c.
Does a CFormView have to be parented by a FrameWnd?
Does a CFormView have to be associated with a CDocument?
Can anyone shed any light on the error message?
Some code sipets that might be useful are below (I have not yet made any modifications to the CFormView derived classes):
in the CView derived class' OnInitialUpdate,
// TODO: Add your specialized code here and/or call the base class
// Create the Tab Control
DWORD dwStyle = TCS_TABS | TCS_SINGLELINE | TCS_RAGGEDRIGHT | WS_CHILD | WS_VISIBLE;
if (!m_wndTabs.Create(dwStyle, TabRect, this, TAB_CONTROL_ID))
TRACE0("Failed to create tab control\n");
In the CTabCtrl derived class' OnCreate handler:
if (CTabCtrl::OnCreate(lpCreateStruct) == -1)
// TODO: Add your specialized creation code here
TabCtrlItem.mask = TCIF_TEXT;
TabCtrlItem.cchTextMax = 0;
TabCtrlItem.iImage = 0;
// for now an temporary size adjustment
TabRect.top += 30;
TabRect.right -= 10;
CreateContext.m_pNewViewClass = RUNTIME_CLASS(GENERAL_VIEW);
CreateContext.m_pCurrentDoc = NULL;
CreateContext.m_pNewDocTemplate = NULL;
CreateContext.m_pLastView = NULL;
CreateContext.m_pCurrentFrame = NULL;
WS_CHILD | WS_VISIBLE,
TabCtrlItem.pszText = "General";