分割窗口问题?
我在程序中进行窗口分割,先分成左右,再将左分成上下,现遇到一个问题:程序运行是左边分割成上下窗口的部分根本就没有显示出来我设置的大小,(也就是说分割条与主框架紧靠着)这是为什么呢?,如果不是把第一个进行分割的话却正常显示。
我的代码:
m_wndSplitter.CreateStatic(this,1,2);
m_wndSplitter2.CreateStatic(&m_wndSplitter,2,1);
m_wndSplitter2.CreateView(0,0,RUNTIME_CLASS(CSendView),CSize(150,150),pContext);
m_wndSplitter2.CreateView(1,0,RUNTIME_CLASS(CAppendView),CSize(150,200),pContext);
m_wndSplitter.CreateView(0,1,RUNTIME_CLASS(CWinPoPupView),CSize(150,100),pContext);
SetActiveView((CView*)m_wndSplitter2.GetPane(0,0));
问题点数:10、回复次数:4Top
1 楼xwind()回复于 2000-10-07 22:20:00 得分 3
在msdn中对CreateStatic的帮助中有这么一段话:
When you create a static splitter window, you must at the same time create all its panes.
我想主要就是因为这个原因吧,具体你可以看看msdn的例程viewex,下面就是它的代码:
BOOL C3WaySplitterFrame::OnCreateClient(LPCREATESTRUCT lpcs,
CCreateContext* pContext)
{
// create a splitter with 1 row, 2 columns
if (!m_wndSplitter.CreateStatic(this, 1, 2))
{
TRACE0("Failed to CreateStaticSplitter\n");
return FALSE;
}
// add the first splitter pane - the default view in column 0
if (!m_wndSplitter.CreateView(0, 0,
pContext->m_pNewViewClass, CSize(200, 50), pContext))
{
TRACE0("Failed to create first pane\n");
return FALSE;
}
// 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
2, 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 FALSE;
}
// 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(CTextView), CSize(0, cyText), pContext))
{
TRACE0("Failed to create second pane\n");
return FALSE;
}
if (!m_wndSplitter2.CreateView(1, 0,
RUNTIME_CLASS(CColorView), CSize(0, 0), pContext))
{
TRACE0("Failed to create third pane\n");
return FALSE;
}
// it all worked, we now have two splitter windows which contain
// three different views
return TRUE;
}
Top
2 楼RedFire(丹焰)回复于 2000-10-08 09:31:00 得分 7
有没有人知道?Top
3 楼RedFire(丹焰)回复于 2000-10-08 10:34:00 得分 0
我也不知道具体的原因,但是你可以在创建视之后更改一下大小。在
SetActiveView((CView*)m_wndSplitter2.GetPane(0,0));
前面加上如下两条语句就行了。
// 注意:前面一个是理想大小,后面一个是最小大小
m_wndSplitter.SetColumnInfo(0, 150, 150);
m_wndSplitter.RecalcLayout( );
Top
4 楼vcmfc(【痛苦的虫虫】)回复于 2000-10-08 13:43:00 得分 0
谢谢RedFire,能否交个朋友。Top




