窗体dlg1上放着tab控件,这个tab控件上不能放控件。所以在dlg2上建立好要放的控件,然后在tab上加载,,然后窗体dlg1的窗体大小变化时候,如何实现dlg2上的所有东西的大小也随之变化。已经实现了dlg1上tab控件随着dlg1的变化而变化。但是就是不能实现tab控件上的dlg2窗体的变化以及其上的控件变化。比如说dlg2上放着IDC_LIST1列表控件。 一下是dlg1上的代码:
void CQualityControlDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy); // TODO: 在此处添加消息处理程序代码
int y=cy - currect.Height(); //垂直增量
int x=cx - currect.Width(); //水平增量
if(GetDlgItem(IDC_TAB1))
{
CRect r[4];
GetDlgItem(IDC_TAB1)->GetWindowRect(&r[0]); ScreenToClient(&r[0]); r[0].right=r[0].right+x;
r[0].bottom=r[0].bottom+y; GetDlgItem(IDC_TAB1)->MoveWindow(r[0]); GetClientRect(&currect);
}
}
void CQualityControlDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy); // TODO: 在此处添加消息处理程序代码
int y=cy - currect.Height(); //垂直增量
int x=cx - currect.Width(); //水平增量
if(GetDlgItem(IDC_TAB1))
{
CRect r[4];
GetDlgItem(IDC_TAB1)->GetWindowRect(&r[0]); ScreenToClient(&r[0]); r[0].right=r[0].right+x;
r[0].bottom=r[0].bottom+y; GetDlgItem(IDC_TAB1)->MoveWindow(r[0]); GetClientRect(&currect);
}
}
也是要处理DLG2的ONSIZE消息啊