1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| CFormView::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
CRect l_formRect;
GetClientRect(&l_formRect);
// get pointer to the control to be resized dynamically
CTreeCtrl* pTreeCtrl=NULL;
pTreeCtrl = (CTreeCtrl *)GetDlgItem(IDC_MENUGAUCHE);
//Calculate the new width of the control to be resized
long newWidthTree = l_formRect.Width()/3;
if(newWidthTree > 250)
newWidthTree = 250;
long newWidthTab = l_formRect.Width() - newWidthTree ;
long newHeightTree = l_formRect.Height();
// Now resize the control dynamically by calling MoveWindow
pTreeCtrl->MoveWindow(l_formRect.TopLeft().x+5, l_formRect.TopLeft().y+25, (long)newWidthTree, (long)newHeightTree-25, TRUE);
// repaint control
pTreeCtrl->RedrawWindow();
} |