关于 vc++ 单文档多视以后, 实现 窗口拆分的一个问题(请高手帮助看一下)
我在设计一个软件,使单文档的程序,主页面显示的是一些画图的曲线(在对话框中固定了,不能改变大小)因此我想通控制按钮,如一个“新增窗口”命令来动态新建一个窗口(目前已经实现)。
问题是我想在新建的窗口中实现静态拆分,我将如下代码加入我新建窗口的视类中,执行后没有效果。是不是我用于新建窗口的Frame模板是CMainFrame的原因,还是拆分只能在CMainFrame中实现不能在view类中实现?请高手指点,并帮助解决多谢!
int CSp2View::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: 在此添加您专用的创建代码
// //获得窗口的创建信息指针
CCreateContext *pContext=(CCreateContext*) lpCreateStruct->lpCreateParams;
if (!m_wndSplitter.CreateStatic(this, 1, 2))
{
TRACE0("Failed to CreateStaticSplitter\n");
return -1;
}
// add the first splitter pane - the default view in column 0
if (!m_wndSplitter.CreateView(0, 0,
pContext->m_pNewViewClass, CSize(400, 0), pContext))
{
TRACE0("Failed to create first pane\n");
return -1;
}
// add the second splitter pane - which is a nested splitter with 2 rows
if (!m_wndSplitter2.CreateStatic(
&m_wndSplitter, // our parent window is the first splitter
3, 1, // the new splitter is 2 rows, 1 column
WS_CHILD | WS_VISIBLE | WS_BORDER, // style, WS_BORDER is needed
m_wndSplitter.IdFromRowCol(0, 1)
// new splitter is in the first row, 2nd column of first splitter
))
{
TRACE0("Failed to create nested splitter\n");
return -1;
}
// now create the two views inside the nested splitter
//int cyText = max(lpcs->cy - 70, 20); // height of text pane
if (!m_wndSplitter2.CreateView(0, 0,
RUNTIME_CLASS(CSpeedView), CSize(0, 150), pContext))
{
TRACE0("Failed to create second pane\n");
return -1;
}
if (!m_wndSplitter2.CreateView(1, 0,
RUNTIME_CLASS(CGearView), CSize(0, 150), pContext))
{
TRACE0("Failed to create third pane\n");
return -1;
}
if (!m_wndSplitter2.CreateView(2, 0,
RUNTIME_CLASS(CHeartView), CSize(0, 0), pContext))
{
TRACE0("Failed to create third pane\n");
return -1;
}
return 0;
}