Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
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.
Posted

1 solution

Try to react to the WM_SIZE dialog's message,
then to move your controls explicitly :)
C++
// 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();
}
 
Share this answer
 
v2
Comments
GopakumarP 21-Jun-12 1:41am    
How??
can you put sample??
Eugen Podsypalnikov 21-Jun-12 2:11am    
Take it :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900