我用SplitterWnd类将一个主窗体分割成了左边一块(View1),右(上View2,下View3)两块,我现在想让主窗体改变尺寸的时候让两个窗体按比例调整大小,请问如何解决?
我现在的做法是先将三个子窗体的指针保存在主体体中,分别为pView1,pView2,pView3,重载主窗体的OnSize()函数。代码如下:void CMainFrame::OnSize(UINT nType, int cx, int cy)
{
RECT rect1;
RECT rect2; RECT recttmp; memset(&rect1,0,sizeof(RECT));
memset(&rect2,0,sizeof(RECT));
memset(&rect3,0,sizeof(RECT));
memset(&recttmp,0,sizeof(RECT)); pView1->GetClientRect(&rect1);
pView2->GetClientRect(&rect2);
pView3->GetClientRect(&rect3);         CFrameWnd::OnSize(nType, cx, cy); recttmp.left=0;
recttmp.right=rect1.right*cx/(rect1.right+rect2.right);
recttmp.top=0;
recttmp.bottom=cy;
pView1->MoveWindow(&recttmp); recttmp.left=recttmp.right;
recttmp.right=cy;
recttmp.bottom=rect2.bottom*cy/(rect2.bottom+rect3.bottom);
pView2->MoveWindow(&recttmp); recttmp.top=recttmp.bottom;
recttmp.bottom=cy;
pView3->MoveWindow(&recttmp);
}运行的结果全乱了。