2025年4月12日 星期六 乙巳(蛇)年 正月十三 设为首页 加入收藏
rss
您当前的位置:首页 > 计算机 > 编程开发 > VC/VC++

设置对话框弹出位置(SetWindowPos)

时间:09-16来源:作者:点击数:37

设置对话框弹出位置在屏幕中心

  • //调整对话框的位置test 2023.6.16
  • CRect rectMain;
  • GetWindowRect(&rectMain);
  • CRect rectScreen;
  • SystemParametersInfo(SPI_GETWORKAREA,0,&rectScreen,0);
  • int nWidth=rectMain.Width();
  • int nHeight=rectMain.Height();
  • int nLeft=rectScreen.left+(rectScreen.Width()-nWidth)/2;
  • int nTop=rectScreen.top+(rectScreen.Height()-nHeight)/2;
  • SetWindowPos(NULL,nLeft,nTop,nWidth,nHeight,SWP_NOSIZE);
  • //end
方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门
本栏推荐