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

查看:48
本文介绍了在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天全站免登陆