VC对话框大小和位置设置
来源:互联网 发布:ultrawebgrid绑定数据 编辑:程序博客网 时间:2024/05/16 07:26
软件开发中,我们通常需要设置对话框到我们需要的大小,并且希望能在我们希望的位置显示,那么就需要设置对话框的大小和位置了。
步骤:
1.新建对话框
新建对话框应用程序,为了方便对比,我们还另外新建两个对话框。
2.设置对话框大小和位置
为了方便对比,一个对话框使用默认效果,另一个对话框重写OnInitDialog函数。
BOOL CDialog2::OnInitDialog() {CDialog::OnInitDialog();//对话框背景图片宽和高const int nBkBmpWidth = 480;const int nBkBmpHeight = 300;int xPos = 0;int yPos = 0;//获得电脑显示器的像素宽度和像素高度int ax = GetDC()->GetDeviceCaps(HORZRES) - nBkBmpWidth;int ay = GetDC()->GetDeviceCaps(VERTRES) - nBkBmpHeight;int nWidth = 0;int nHeight = 0;if(ax <= 0){ax = 0;}else{ax = ax/2;}if(ay <= 0){ay = 0;}else{ay = ay/2;}RECT clientRect;RECT rt;clientRect.left = ax;clientRect.top = ay;clientRect.right = clientRect.left + nBkBmpWidth;clientRect.bottom = clientRect.top + nBkBmpHeight;MoveWindow(&clientRect);return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE}
设置后效果
源码下载
0 0
- VC对话框大小和位置设置
- 设置对话框大小和位置
- 对话框消除黑色背景、边框,设置对话框大小和位置
- VC改变控件或对话框的大小和位置方法
- MFC 设置弹出对话框的位置、大小和风格 SetWindowPos
- Android 自定义对话框,可设置大小和显示位置,并设置点击其他位置不消失
- VC++设置对话框显示的起始位置
- VC中自动改变控件位置和大小的对话框类
- VC中自动改变控件位置和大小的对话框类
- VC中自动改变控件位置和大小的对话框类
- VC中自动改变控件位置和大小的对话框类
- VC中自动改变控件位置和大小的对话框类
- VC中自动改变控件位置和大小的对话框类
- VC中自动改变控件位置和大小的对话框类
- 《VC中自动改变控件位置和大小的对话框类》详细使用方法
- VC中自动改变控件位置和大小的对话框类
- VC中自动改变控件位置和大小的对话框类
- VC中自动改变控件位置和大小的对话框类[转]
- 【ASP】Win7环境下IIS的配置
- [汇文教育]iOS内支付(IAP)研究
- Maximum Depth of Binary Tree 二叉树的最大深度
- MySQl命令
- mongodb 增加管理员及普通用户
- VC对话框大小和位置设置
- Binary Tree Level Order Traversal II 从下向上按层遍历二叉树
- A program to compute word length of a machine
- iOS中动画实现技术主要是:Core Animation。
- [csu oj]1553: Good subsequence(水题)
- Coursera上Andrew Ng机器学习课程总结(一)
- Balanced Binary Tree 平衡二叉树的判断
- String to Integer
- [图像]摄像机标定(2) 张正友标定推导详解