在子窗体的OnInitDialog()函数体中,增加如下代码:
//获取屏幕水平分辨率
int iWidth = GetSystemMetrics(SM_CXSCREEN);
//获取屏幕垂直分辨率
int iHeight = GetSystemMetrics(SM_CYSCREEN);
// 获取窗体的大小
CRect wRect;
GetWindowRect(&wRect);
ClientToScreen(&wRect);
// 移动子窗体在窗体正中间
MoveWindow((iWidth-wRect.Width())/2, (iHeight - wRect.Height())/2, wRect.Width(), wRect.Height());