In VC++ 6.0 (MFC), how the the controls eg : Button, EditBox, and Static Text can be move from bottom of the form to top of the form.
+3
A:
You can use CWnd::MoveWindow() to move controls. CWnd::GetDlgItem() will retrieve a CWnd for a given control id.
Some pseudocode to be called from inside the class of the window that is parent of the controls:
RECT windowRect;
GetClientRect( &windowRect );// Bounds of the current window
CWnd* controlWindow = GetDlgItem( controlId );
RECT controlRect;
controlWindow->GetWindowRect( &controlRect );//control rectangle
ScreenToClient( &controlRect );//control rectangle in the coordinate system of the parent
const int vertOffset = windowRect.top - controlRect.top;//how much to adjust
controlRect.top += vertOffset;
controlRect.bottom += vertOffset;
controlWindow->MoveWindow( &controlRect );
sharptooth
2009-04-28 04:55:29
can you show the sample of the code or any example, that i will get more clear.
2009-04-28 04:59:25
the sample code looks good to me -
Jeff
2009-04-28 05:12:02