RECT rc;
DWORD dwWidth,dwHeight;
GetWindowRect(hWnd,&rc);//获取窗口的矩形区域
dwWidth=rc.right-rc.left;//计算窗口宽度
dwHeight=rc.bottom-rc.top;//计算窗口高度
SystemParametersInfo(SPI_GETWORKAREA,NULL,&rc,NULL);//取出桌面工作区
SetWindowPos(hWnd,NULL,(rc.right-dwWidth)/2,(rc.bottom-dwHeight)/2,0,0,SWP_NOZORDER|SWP_NOSIZE|SWP_NOREDRAW);
WINDOW SDK API 窗口居中
最新推荐文章于 2022-01-11 20:38:59 发布