模态对话框是DoModal出来的,而非模态对话框是Create创建的。
CTestDlg* oCTestDlg;
oCTestDlg = new CTestDlg (this);
oCTestDlg->Create( IDD_MEDIA_SERVER_SPACE_ALERT, this );
CRect rect;
this->GetClientRect( &rect );
CRect rectDisk;
oCTestDlg->GetWindowRect( &rectDisk );
oCTestDlg->SetWindowPos( NULL,
rect.CenterPoint().x - rectDisk.Width() / 2,
rect.CenterPoint().y - rectDisk.Height() / 2,
rectDisk.Width(),
rectDisk.Height(),
SWP_NOZORDER
);
oCTestDlg->ShowWindow( SW_SHOW );
上例为在父对话框的中间弹出非模态对话框。