对话框调整大小时,移动MFC按钮 [英] Move MFC Button, While dialog resizing

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

问题描述



我有一个带有一些按钮的对话框应用程序.但是在重新设置对话框大小时,按钮不会自动重新放置.

提前感谢您能否帮助我解决此问题.

Hi,

I had a dialog application with some buttons. But while re-sizing the dialog, the buttons are not automatically repositioned.

Could you please help me to fix this problem, thanks in advance.

推荐答案

尝试对WM_SIZE对话框的消息做出反应,
然后显式移动您的控件:)
Try to react to the WM_SIZE dialog''s message,
then to move your controls explicitly :)
// CPoint CYourDialog::m_cLastClientBottomRight
// is initalized in CYourDialog::OnInitDialog()
// as right-bottom point of its client rectangle

// Assumed, the OK button must be adapted in both directions:
void CYourDialog::OnSize(UINT nType, int cx, int cy)
{
  CRect crClient;
  GetClientRect(crClient);

  if (m_cBtnOK.GetSafeHwnd()) {
    CRect crControl;
    m_cBtnOK.GetWindowRect(crControl);
    ScreenToClient(crControl);

    crControl.OffsetRect(crClient.BottomRoght() - m_cLastClientBottomRight);
    m_cBtnOK.MoveWindow(crControl);
    m_cBtnOK.Invalidate();
  }

  m_cLastClientBottomRight = crClient.BottomRight();
}


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

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