我使用过CreateStatic& CreateView将“C(类名)视图”拆分为多个窗格(如(1x2),(3x3)),使用按钮控件选择行数和列数。
现在,当我点击1x1(这意味着我要删除任何窗格)时,ASSERT(n_Row> 1&& n_Col> 1)显然在CSplitterWnd :: CreateStatic内失败。
我如何处理“无窗格”情况?
这是DisplaySingleFrame()函数(删除窗格)
CN00bSplitApp* pApp = (CN00bSplitApp*)AfxGetApp();
CView * pActiveView = NULL;
if(pActiveView == NULL)
{
if(m_pSplitter)
pActiveView = (CView*)m_pSplitter->GetPane(0,0);
else
pActiveView = (CN00bSplitView *)GetActiveView();
}
m_iPrevColLayout = m_iRowLayout;
m_iPrevRowLayout = m_iColLayout;
m_iRowLayout = 0;
m_iColLayout = 0;
ShowWindow(SW_HIDE);
CRect rect(0,0,0,0);
pActiveView->GetClientRect(rect);
CDocument * pDoc= pActiveView->GetDocument();
pActiveView->DestroyWindow();
pActiveView = NULL;
if(m_pSplitter)
{
m_pSplitter->DestroyWindow();
delete m_pSplitter;
m_pSplitter = NULL;
}
CDocTemplate* pDocTemplate = pApp->m_pDocTemplate;
CCreateContext context;
context.m_pNewViewClass= RUNTIME_CLASS(CN00bSplitView);
context.m_pCurrentDoc=(CN00bSplitDoc*)pDocTemplate->CreateNewDocument();
context.m_pLastView=pActiveView;
CView* p = (CView*)CreateView(&context, AFX_IDW_PANE_FIRST);
SetActiveView(p);
p->OnInitialUpdate();
RecalcLayout();
ShowWindow(SW_SHOW);
这会在“context.m_pCurrentDoc =(CN00bSplitDoc *)pDocTemplate-> CreateNewDocument();”
中抛出未处理的异常答案 0 :(得分:0)
我没有在m_pDocTemplate=pDocTemplate
的InitInstance中初始化C(classname)App
。
解决问题。