Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Resizing frame with controls 1

Status
Not open for further replies.

LnOrS

Programmer
Apr 3, 2001
66
PT
Hi,

How can I resize a frame with controls (static, sliders, edit)?
After capturing WM_SIZE message I'll have to move and stretch some controls, how can I do that?

Thanks,
Luís Silva
 
There are a few ways to do this, and of course it all depends on what needs to be resized. Do you have a button you want to keep in the same place, an edit box you want to stretch to the end of the dialog, or a tree ctrl you want to enlarge to take advantage of extra room? I any case I'll give you this to get started. Here is how you would make an edit box longer when the window gets bigger.

void CMyDialog::OnSize(UINT nType, int cx, int cy)
{
CMyDialog::OnSize(nType, cx, cy);
CEdit* pEdit = (CEdit*)GetDlgItem(IDC_MYEDIT_CONTROL);

CRect winRect, ctrlRect;
GetClientRect(&winRect);

WINDOWPLACEMENT ctrlPlacement;

if(pEdit != NULL)
{
pEdit->GetWindowPlacement(&ctrlPlacement);
ctrlRect = ctrlPlacement.rcNormalPosition;

//move right edge of edit box 10 from the border
ctrlRect.right = winRect.right - 10;
pEdit->MoveWindow(ctrlRect, TRUE);
}

}

This should get you started into more complex resizing stuff. All resizing code will use these functions, it's just how you mess with the rects to get the desired results. Good Luck.

-bitwise
 
Thanks bitwise,

You really helped me!
In this situation I think winRect is not necessary because there's a cx and a cy, but I kept it any way.

Kind Regards,
Luís Silva
 
Cool, glad I could help. I remember the days spent on writing resizing code - annoying stuff.

cya,
-bitwise
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top