如何调整MFC对话框的大小 [英] How to Resize MFC dialog

查看:1406
本文介绍了如何调整MFC对话框的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个对话框,我想用代码重新编写这个dilog,但我不知道怎么做。

I have a dialog and I want to rezie this dilog with code, but I don''t konw how to do it.

推荐答案

你可以使用SetWindowPos :

You can use SetWindowPos :
this->SetWindowPos(NULL,0,0,newWidth,newHeight,SWP_NOMOVE | SWP_NOZORDER);



这会改变大小对话框,但你需要使用相同的函数,但使用控件的CWnd移动和调整对话框内的控件。

你应该把这段代码放在对话框的OnSize成员中使用提供的客户端宽度和高度。


This will change the size of the dialog, but you will need to move and resize the control inside the dialog using the same function but with the CWnd of the control.
You should put this code in the OnSize members of the dialog and use the client width and height provided.

CWnd* pCtrl = GetDlgItem(IDC_CONTROL1);
// keep it centered
CRect rectCtrl;
pCtrl->GetWindowRect(rectCtrl);
pCtrl->SetWindowPos(NULL,(dialogWidth-rectCtrl.Width())/2,(dialogHeight-rectCtrl.Height())/2,0,0,SWP_NOSIZE | SWP_NOZORDER);


这篇关于如何调整MFC对话框的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆