我做了一个切分窗口,希望能够控制该切分窗口,使其能够创建不同的View类。在
CMainFrame中的BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/,CCreateContext* pContext)函数中,有如下语句:if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CLeftView), CSize(220, 100), pContext) || !m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CSDCS_NCManagerView), CSize(100, 100), pContext))
{
m_wndSplitter.DestroyWindow();
return FALSE;
}我在该语句之后加入另外两句话:
m_wndSplitter.DeleteView(0,1) ;//删除右边的CSDCS_NCManagerView
m_wndSplitter.CreateView(0,1, RUNTIME_CLAS(CRemoteStationCtrlView),
CSize(100,100), pContext ) ; //创建一个新的FormView。上面是可以的,但是,我在别的函数中调用上述两个语句却出错,不知道如何是好。
切盼那位高人能够不吝赐教!!! 急。
CMainFrame中的BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/,CCreateContext* pContext)函数中,有如下语句:if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CLeftView), CSize(220, 100), pContext) || !m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CSDCS_NCManagerView), CSize(100, 100), pContext))
{
m_wndSplitter.DestroyWindow();
return FALSE;
}我在该语句之后加入另外两句话:
m_wndSplitter.DeleteView(0,1) ;//删除右边的CSDCS_NCManagerView
m_wndSplitter.CreateView(0,1, RUNTIME_CLAS(CRemoteStationCtrlView),
CSize(100,100), pContext ) ; //创建一个新的FormView。上面是可以的,但是,我在别的函数中调用上述两个语句却出错,不知道如何是好。
切盼那位高人能够不吝赐教!!! 急。
m_wndSplitter.CreateView(0,1, RUNTIME_CLAS(CRemoteStationCtrlView),
CSize(100,100), pContext ) ; //创建一个新的FormView。
其它函数下你的这个pContext参数要么没有定义,要不该结构赋值不正确。
thepContext = pContext;
然后在别的函数中使用:
m_wndSplitter.DeleteView(0,1) ;//删除右边的CSDCS_NCManagerView
m_wndSplitter.CreateView(0,1, RUNTIME_CLAS(CRemoteStationCtrlView),
CSize(100,100), thepContext ) ; //创建一个新的FormView。
经跟踪得知,thepContext 和 原来赋值时一样。
thepContext = pContext;//thepContext是指向pContext的指针。
//其它函数中pContext已不存在,所以thepContext也无效了。//定义成CCreateContext thepContext;再赋值就行了。不要使用指针
m_wndSplitter.RecalcLayout();