0

我使用 CreateStatic 和 CreateView 将“C(classname)View”拆分为多个窗格(如 (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();”处引发未处理的异常

4

1 回答 1

0

我没有m_pDocTemplate=pDocTemplateC(classname)App.

解决问题。

于 2012-05-11T09:23:37.133 回答