且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 MFC 中创建可调整大小的 CDialog?

更新时间:2023-01-14 09:29:16

在 RC 资源文件中,如果对话框有类似这样的样式,它将是固定大小的:

In the RC resource file if the dialog has this style similar to this it will be fixed size:

IDD_DIALOG_DIALOG DIALOGEX 0, 0, 320, 201
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU

如果对话框有这种风格,它会很大:

If the dialog has this style it will be sizeable:

IDD_DIALOG_DIALOG DIALOGEX 0, 0, 320, 201
STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME

使用这些可调整大小的框架选项,对话框将可以重新调整大小,但您仍需要做大量工作来处理 WM_SIZE 消息,以管理对话框中控件的大小和位置.

With these sizable frame options the dialog will be re-sizeable but you will still need to do a lot of work handling the WM_SIZE message to manage the sizing an positioning of the controls within the dialog.