MFC 窗口分割时老是不能正确显示尺寸问题 求MFC大神~~
这是我得到的结果用鼠标拖动才能得到下面结果这面是我的分割代码,求大神告知原因this->GetClientRect(&rect);CStringstr;str.Forma...
这是我得到的结果 用鼠标拖动才能得到下面结果
这面是我的分割代码,求大神告知原因
this->GetClientRect(&rect);
CString str;
str.Format("%d, %d",rect.Width(),rect.Height());
MessageBox(str);
this->m_splitter1.CreateStatic(this,3,1);
//this->m_splitter1.CreateView(0,0,RUNTIME_CLASS(CDebugTwoView),CSize(rect.Width(),rect.Height()*3/5),pContext);
this->m_splitter2.CreateStatic(&m_splitter1,1,3,WS_CHILD | WS_VISIBLE,m_splitter1.IdFromRowCol(0,0));
this->m_splitter2.CreateView(0,0,RUNTIME_CLASS(CBottomEditView),CSize(rect.Width()/5,rect.Height()*3/5),pContext);
this->m_splitter2.CreateView(0,1,RUNTIME_CLASS(CDebugTwoView),CSize(rect.Width()*3/5,rect.Height()*3/5),pContext);
this->m_splitter2.CreateView(0,2,RUNTIME_CLASS(CBottomEditView),CSize(rect.Width()/5,rect.Height()*3/5),pContext);
this->m_splitter1.CreateView(1,0,RUNTIME_CLASS(CBottomEditView),CSize(rect.Width(),rect.Height()/5),pContext);
this->m_splitter1.CreateView(2,0,RUNTIME_CLASS(CBottomEditView),CSize(rect.Width(),rect.Height()/5),pContext); 展开
这面是我的分割代码,求大神告知原因
this->GetClientRect(&rect);
CString str;
str.Format("%d, %d",rect.Width(),rect.Height());
MessageBox(str);
this->m_splitter1.CreateStatic(this,3,1);
//this->m_splitter1.CreateView(0,0,RUNTIME_CLASS(CDebugTwoView),CSize(rect.Width(),rect.Height()*3/5),pContext);
this->m_splitter2.CreateStatic(&m_splitter1,1,3,WS_CHILD | WS_VISIBLE,m_splitter1.IdFromRowCol(0,0));
this->m_splitter2.CreateView(0,0,RUNTIME_CLASS(CBottomEditView),CSize(rect.Width()/5,rect.Height()*3/5),pContext);
this->m_splitter2.CreateView(0,1,RUNTIME_CLASS(CDebugTwoView),CSize(rect.Width()*3/5,rect.Height()*3/5),pContext);
this->m_splitter2.CreateView(0,2,RUNTIME_CLASS(CBottomEditView),CSize(rect.Width()/5,rect.Height()*3/5),pContext);
this->m_splitter1.CreateView(1,0,RUNTIME_CLASS(CBottomEditView),CSize(rect.Width(),rect.Height()/5),pContext);
this->m_splitter1.CreateView(2,0,RUNTIME_CLASS(CBottomEditView),CSize(rect.Width(),rect.Height()/5),pContext); 展开
展开全部
在你创建分隔栏的窗口中,收到WM_SIZE消息时重设分隔栏的Row或者Column的信息,你的窗口应该是Row(行)。设置完重新RecalLayout即可。
void CTopRightWnd::OnSize(UINT nType, int cx, int cy)
{
CFrameWnd::OnSize(nType, cx, cy);
if (m_pCellsWnd || m_pInfoWnd)
{
CRect rcSplitter;
GetWindowRect(&rcSplitter);
int nHeight = rcSplitter.Height() - 80;
if (nHeight > 0)
{
// Adjust splitter window with ideal size.
m_wndSplitter.SetRowInfo( 0, 80, 80 );
m_wndSplitter.SetRowInfo( 1, nHeight, 10 );
m_wndSplitter.RecalcLayout();
}
}
}
void CTopRightWnd::OnSize(UINT nType, int cx, int cy)
{
CFrameWnd::OnSize(nType, cx, cy);
if (m_pCellsWnd || m_pInfoWnd)
{
CRect rcSplitter;
GetWindowRect(&rcSplitter);
int nHeight = rcSplitter.Height() - 80;
if (nHeight > 0)
{
// Adjust splitter window with ideal size.
m_wndSplitter.SetRowInfo( 0, 80, 80 );
m_wndSplitter.SetRowInfo( 1, nHeight, 10 );
m_wndSplitter.RecalcLayout();
}
}
}
更多追问追答
追问
请问您说的m_wndSplitter对应的是我程序中的m_splitter1还是m_splitter2? 还有那些行信息是什么意思? 谢谢
追答
是的,m_wndSplitter就是分隔栏。
SetRowInfo就是设置第几行的窗口的长和宽,0代表的是第一行。
同理,SetColumnInfo是设置列的。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询