在 MFC 中调整控件大小 [英] Resizing Controls in MFC

查看:25
本文介绍了在 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 中调整控件大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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