Resizing Controls in MFC(在 MFC 中调整控件大小)
问题描述
我正在编写一个程序,它有两个窗格(通过 CSplitter),但是我在弄清楚如何调整每个帧中的控件大小时遇到了问题.为简单起见,有人可以告诉我如何为带有单个 CEdit 控件的基本框架执行此操作吗?
I am writing a program which has two panes (via CSplitter), however I am having problems figuring out out to resize the controls in each frame. For simplicity, can someone tell me how I would do it for a basic frame with a single CEdit control?
我很确定这与 CEdit::OnSize() 函数有关...但我并没有真正到达任何地方...
I'm fairly sure it is to do with the C:OnSize() function... But I'm not really getting anywhere...
谢谢!:)
推荐答案
当你的框架收到 OnSize 消息时,它会给你新的宽度和高度 - 你可以简单地调用 CEdit SetWindowPos 方法传递这些值.
When your frame receives an OnSize message it will give you the new width and height - you can simply call the CEdit SetWindowPos method passing it these values.
假设 CMyPane 是您的拆分器窗格,它包含您在 OnCreate 中创建的名为 m_wndEdit 的 CEdit:
Assume CMyPane is your splitter pane and it contains a CEdit you created in OnCreate called m_wnd
void CMyPane::OnSize(UINT nType, int cx, int cy)
{
m_wndEdit.SetWindowPos(NULL, 0, 0, cx, cy, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
}
这篇关于在 MFC 中调整控件大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 MFC 中调整控件大小
基础教程推荐
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- CString 到 char* 2021-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
