15,979
社区成员
发帖
与我相关
我的任务
分享
void CAutoFitDlg::OnSize(UINT nType, int cx, int cy)
{
//计算窗口宽度和高度的改变量
int nIncrementX = cx - m_nWinWidth;
int nIncrementY = cy - m_nWinHeight;
INT_PTR nCount = m_listCtrlTag.GetSize();
for (int i=0; i<nCount; i++)
{
//获取变化控制系数
int nMoveXPercent = m_listCtrlTag[i]->m_nMoveXPercent;
int nMoveYPercent = m_listCtrlTag[i]->m_nMoveYPercent;
int nZoomXPercent = m_listCtrlTag[i]->m_nZoomXPercent;
int nZoomYPercent = m_listCtrlTag[i]->m_nZoomYPercent;
CWnd* pWndCtrl;
//获取控件指针
pWndCtrl = m_listCtrlTag[i]->m_pWnd;
if(IsWindow(pWndCtrl->GetSafeHwnd()))
{
int nLeft = m_listCtrlTag[i]->m_rectWnd.left;
int nTop = m_listCtrlTag[i]->m_rectWnd.top;
int nWidth = m_listCtrlTag[i]->m_rectWnd.Width();
int nHeight = m_listCtrlTag[i]->m_rectWnd.Height();
//设置新的位置参数
nLeft += (nIncrementX*nMoveXPercent/100);
nTop += (nIncrementY*nMoveYPercent/100);
nWidth += (nIncrementX*nZoomXPercent/100);
nHeight += (nIncrementY*nZoomYPercent/100);
// 把控件移动到新位置
pWndCtrl->MoveWindow(nLeft, nTop, nWidth, nHeight);
}
}
CDialog::OnSize(nType, cx, cy);
}