子对话框 GetClientRect函数 得到的值为什么不一样
在主对话框初始化函数中加入下面代码:
CRect rc;
GetClientRect(rc);
for(int i =0;i<4;i++)
{
newDlg[i].Create(IDD_DIALOG1,this);// 在主框中创建四个子对话框 子框和主框是不同类
newDlg[i].ShowWindow(SW_SHOW);
}
newDlg[0].MoveWindow(0,0,rc.Width()/2,rc.Height()/2,TRUE);//子对话框平分主框区域
newDlg[1].MoveWindow(rc.Width()/2,0,rc.Width(),rc.Height()/2,TRUE);
newDlg[2].MoveWindow(0,rc.Height()/2,rc.Width()/2,rc.Height(),TRUE);
newDlg[3].MoveWindow(rc.Width()/2,rc.Height()/2,rc.Width(),rc.Height(),TRUE);
然后四个子对话框中OnPaint函数中GetClientRect 得到的值不一样,怎么回事啊 ,他们的大小应该是一样的才对。
追问:你的代码不和我的一样吗 问题还是没解决......
答案:MoveWindow的第3和第4个参数是宽度和高度
newDlg[0].MoveWindow(0, 0, rc.Width()/2, rc.Height()/2, TRUE);
newDlg[1].MoveWindow(rc.Width()/2, 0, rc.Width()/2, rc.Height()/2, TRUE);
newDlg[2].MoveWindow(0, rc.Height()/2, rc.Width()/2, rc.Height()/2, TRUE);
newDlg[3].MoveWindow(rc.Width()/2, rc.Height()/2, rc.Width()/2, rc.Height()/2, TRUE);
其他:显示的时候,这4个对话框的长宽是一样的吗? 应该是整除除不尽造成的吧
上一个:计算e=1+1/2!+1/3!+·····+1/n! 我的程序如下 但是输出错误 求大神帮忙
下一个:怎样将字体和颜色传递到主对话框?