MoveWindow()这个函数的作用:Changes the window's size and position.
参数有两种:BOOL MoveWindow( int x, int y, int nWidth,int nHeight, BOOL bRepaint = TRUE ) x,y为左上角顶点坐标
BOOL MoveWindow(LPCRECT lpRect,BOOL bRepaint = TRUE )
强调:哪个对象(窗体)或指向该对象的指针调用了MoveWindow(),那么就改变该对象(窗体)的大小、位置
举例如下:CMSGOPT *temp=new CMSGOPT;
temp->Create(IDD_DLG_MAIN,this);
temp->ShowWindow(SW_SHOW);
CRect rc;
temp->GetWindowRect(&rc);//注意与this->GetWindowRect(&rc);区别。
//temp->MoveWindow((1024-rc.Width())/2,0,rc.Width(),rc.Height(),1);//居中显示,改变了位置
rc.left=(1024-rc.Width())/2;
rc.right=rc.left+500;
rc.top=0;
rc.bottom=rc.top+500;
temp->MoveWindow(&rc,true);//改变了大小与位置
temp->UpdateWindow();