My MFC program threw an exception. When I tried to debug the compiler pointed to a line in afxtempl.h.
Perhaps, I should give more details. The program is an MDI MFC program that creates three splitters. In the "CChildFrame::OnCreateClient" code shown below, the program successfully creates the first stated pane, but unable to create the second pane.Can any one give me some guidance.(The previous paragraph was added at a much later revision)
template<class TYPE, class ARG_TYPE>
AFX_INLINE TYPE& CArray<TYPE, ARG_TYPE>::ElementAt(INT_PTR nIndex)
{
ASSERT(nIndex >= 0 && nIndex < m_nSize); if(nIndex >= 0 && nIndex < m_nSize)
return m_pData[nIndex];
AfxThrowInvalidArgException();
}
The above function is a memeber function of:
template<class TYPE, class ARG_TYPE = const TYPE&>
class CArray
Honestly, I don't know how to go about location these bug. The program keep running succesfully to cursor located past all the places I suspected the bug might be located. Meaning that all the location I feel the bug could be tested negetive for the bug.
Can anyone give a guidance ?
Further debugging produced the following discovery:
BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
if( !CMDIChildWndEx::OnCreateClient(lpcs,pContext))
{
return FALSE;
}
if(!m_wndSplitter->CreateStatic(this,1,3,WS_CHILD))
{
return FALSE;
}
SIZE size;
CRect rect;
GetClientRect(&rect);
size.cx = (rect.right - m_wndSplitter->GetSplitterWidth())/3;
size.cy = rect.bottom;
m_wndSplitter->CreateView(0,1,RUNTIME_CLASS(CClassManagerView),size,pContext);
m_wndSplitter->CreateView(0,2,RUNTIME_CLASS(CCalcView),size,pContext);
m_wndSplitter->CreateView(0,0,RUNTIME_CLASS(CDisplayView),size,pContext);
SetActiveView((CView *)m_wndSplitter->GetPane(1,2));
m_wndSplitter->ShowWindow(SW_SHOWNORMAL);
m_wndSplitter->UpdateWindow();
return TRUE;
}
I tried to step into the line of code that failed to execute, but visual studio only pointed to "GetThisClass" and just simply sent me to the .cpp code of the class.
Can anyone help me with these further revealations.
By the way, futher debugging showed that the code:
int CCalcView::OnCreate(LPCREATESTRUCT lpCreateStruct)
ran successfully.