按分辨率不同调整对话框大小以及控件大小
2012-06-06 15:31
225 查看
如题,前一阵子为它“清减”了,还好在死了N次N亿个脑细胞后,在网上查找了海量的帖子之后,再加修改总算基本实现了。拿出来跟大家分享,满足一下虚荣心。呵呵!
int xxxDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
CRect rc;
this->GetWindowRect(&rc);
int x,y;
float multiple,H;
//取得分辨率
x=GetSystemMetrics( SM_CXSCREEN );
y=GetSystemMetrics( SM_CYSCREEN );
multiple=(float)x/1024; //如果你布局时的分辨率不是1027*768,就改一下就行了。
H=(float)y/768;
//改变对话框的大小
this->MoveWindow((int)(rc.top*H),(int)(rc.left*multiple),(int)(rc.Width()*multiple),(int)(rc.Height()*H));
return 0;
}
BOOL XXXDlg::OnInitDialog()
{
CDialog::OnInitDialog();
.......................
int x,y;
float multiple,H;
int newx,newy,newwidth,newheight;
x=GetSystemMetrics( SM_CXSCREEN );
y=GetSystemMetrics( SM_CYSCREEN );
multiple=(float)x/1024;
H=(float)y/768;
CWnd *pWndChild=GetWindow(GW_CHILD);
while(pWndChild)
{
CRect rc;
pWndChild->GetWindowRect(&rc);
this->ScreenToClient(&rc);
newx=(int)(rc.left*multiple);
newy=(int)(rc.top*H);
newwidth=(int)(rc.Width()*multiple);
newheight=(int)(rc.Height()*H);
pWndChild->MoveWindow(newx,newy,newwidth,newheight);
pWndChild=pWndChild->GetNextWindow();
}
return TRUE; // return TRUE unless you set the focus to a control
}
int xxxDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
CRect rc;
this->GetWindowRect(&rc);
int x,y;
float multiple,H;
//取得分辨率
x=GetSystemMetrics( SM_CXSCREEN );
y=GetSystemMetrics( SM_CYSCREEN );
multiple=(float)x/1024; //如果你布局时的分辨率不是1027*768,就改一下就行了。
H=(float)y/768;
//改变对话框的大小
this->MoveWindow((int)(rc.top*H),(int)(rc.left*multiple),(int)(rc.Width()*multiple),(int)(rc.Height()*H));
return 0;
}
BOOL XXXDlg::OnInitDialog()
{
CDialog::OnInitDialog();
.......................
int x,y;
float multiple,H;
int newx,newy,newwidth,newheight;
x=GetSystemMetrics( SM_CXSCREEN );
y=GetSystemMetrics( SM_CYSCREEN );
multiple=(float)x/1024;
H=(float)y/768;
CWnd *pWndChild=GetWindow(GW_CHILD);
while(pWndChild)
{
CRect rc;
pWndChild->GetWindowRect(&rc);
this->ScreenToClient(&rc);
newx=(int)(rc.left*multiple);
newy=(int)(rc.top*H);
newwidth=(int)(rc.Width()*multiple);
newheight=(int)(rc.Height()*H);
pWndChild->MoveWindow(newx,newy,newwidth,newheight);
pWndChild=pWndChild->GetNextWindow();
}
return TRUE; // return TRUE unless you set the focus to a control
}
相关文章推荐
- 对话框随屏幕分辨率不同而变化时,TAB控件上的控件如何动态调整大小?
- MFC TableControl控件子对话框 以及子控件 随主对话框 最大化后 调整大小及位置
- 不同分辨率下页面的控件大小调整(待完善)
- 不同分辨率下页面的控件大小调整(待完善)
- 如何实现控件随对话框大小变化而自动调整大小和位置
- MFC如何使控件大小随着对话框大小自动调整
- 【Visual Basic】列表控件ListView的增删改查、模态对话框、禁止窗口调整大小
- MFC如何使控件大小随着对话框大小自动调整
- 根据手机屏幕分辨率设置组件或控件的大小,利用像素更好的适配不同尺寸的机型的动态布局
- 调整Linux下的LVM,以及Swap控件大小
- delphi 程序窗体及控件自适应分辨率(通过ComponentCount遍历改变字体大小以及上下左右)
- Cocos_Lua如何调整模拟器大小以及分辨率
- MFC如何使控件大小随着对话框大小自动调整
- PB让窗口在不同的分辨率下自动调整大小
- 对话框控件自动调整大小, 位置
- MFC如何使控件大小随着对话框大小自动调整
- 如何实现控件随对话框大小变化而自动调整大小和位置
- 通过窗口大小适时调整以及子窗口的动态布局来解决窗口在不同DPI设置下的显示问题
- easysize_动态调整对话框控件位置和大小
- M控件随着FC对话框大小自动调整大小