I have asked you how to resize the interface components in my application before.
Your suggested solution is:
1. Add a handler for WM_SIZE messages and put the code in there.
2. Use ::IsWindow to check the controls are valid before working on them (OnSize will get called once before the controls are valid)
3. Use MoveWindow to move the controls around.
Here is an example from one of my form view app's (CTComply derives off CFormView)
void CTComply::OnSize(UINT nType, int cx, int cy)
CFormView::OnSize(nType, cx, cy);
if ( !::IsWindow(m_edit.m_hWnd) ) return ;
if ( !::IsWindow(m_list.m_hWnd) ) return ;
// get client area
CRect rcClient ;
GetClientRect( &rcClient ) ;
// position edit control
CRect rcEdit ;
m_edit.GetWindowRect( &rcEdit ) ;
ScreenToClient( (LPPOINT)(&rcEdit.left) ) ;
ScreenToClient( (LPPOINT)(&rcEdit.right) ) ;
m_edit.MoveWindow( rcEdit.left, rcEdit.top, rcClient.right - rcEdit.left - 10, rcClient.bottom - rcEdit.top - 10 ) ;
// position list control
CRect rcList ;
m_list.GetWindowRect( &rcList ) ;
ScreenToClient( (LPPOINT)(&rcList.left) ) ;
ScreenToClient( (LPPOINT)(&rcList.right) ) ;
m_list.MoveWindow( rcList.left, rcList.top, rcClient.right - rcList.left - 10, rcList.bottom - rcList.top ) ;
But I still have a problem in re-sizing the interface components.
Eg. when the width of the window is 600
height of the window id 400
a edit box is placed at the window with the upper left co-ordinates is (60,40);
Now, I am resizing the window to width 500, heigth 300.
In this suitation, the edit box need to place at the window with upper-left coordinates (50,30) and the size of the edit box need to be changed also.
From your suggested solution before, I found it only resize the edit box without getting a new upper-left coordinate.
How can I get this?