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();
本文详细介绍了MoveWindow()函数的功能及使用方法,包括如何通过指定坐标和尺寸来调整窗口的位置和大小。此外还提供了具体的代码示例,展示了如何实现窗口的居中显示以及如何同时改变窗口的大小和位置。
791

被折叠的 条评论
为什么被折叠?



