mfc 改变窗口位置大小

来源:互联网 发布:sql定义变量并赋值 编辑:程序博客网 时间:2024/05/02 01:36
void CStoreFilePathDlg::initPosition()
{
   //获取桌面坐标
   CRect r;
   this->GetDesktopWindow()->GetWindowRect(&r);
   //设置窗口参数
   int x,y;
   x = (r.Width() - WINDOW_WIDTH)/2;//左上方X坐标
   y = (r.Height() - WINDOW_HEIGTH)/2;//左上方Y坐标
   //改变窗口大小和位置
   this->SetWindowPos(NULL,x,y,WINDOW_WIDTH,WINDOW_HEIGTH,SWP_SHOWWINDOW);
}