15,979
社区成员
发帖
与我相关
我的任务
分享
void CDataReportDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
// if (m_infoList.GetSafeHwnd())
// {
// m_infoList.MoveWindow(0,0,cx,cy);
// }
CWnd *pWnd;
pWnd = GetDlgItem(IDC_infoList); //获取控件句柄
CRect rect; //获取控件变化前大小
if(nType==1) return; //如果是窗体最小化则什么都不做
if(pWnd)//判断是否为空,因为对话框创建时会调用此函数,而当时控件还未创建
{
pWnd->GetWindowRect(&rect);
ScreenToClient(&rect);//将控件大小转换为在对话框中的区域坐标
rect.right=rect.right*cx/m_rect.Width();
rect.left=rect.left*cx/m_rect.Width();
rect.bottom=rect.bottom*cy/m_rect.Height();
rect.top=rect.top*cy/m_rect.Height();
CString a,b,c,d;
a.Format("%d",rect.right);
b.Format("%d",rect.left);
c.Format("%d",rect.bottom);
d.Format("%d",rect.top);
MessageBox(a+" "+b+" "+c+" "+d);
pWnd->MoveWindow(rect);//设置控件大小
}
GetWindowRect(&m_rect);
}