Stretching a CTreeCtrl
Daniel W. Levi -- DLevi@hworks.com
Tuesday, March 11, 1997
Environment: VC++ 4.2b, NT 4.0
I've got a CFormView-derived class with one control, derived from
CTreeCtrl. I'm looking for behaviour similar to the SQL-Enterpriser
Manager.
I over-rode the View OnSize() to resize tree control so it occupies the
whole view window. This is making the tree control redraw itself very
strangely: (1) the scrollbars are not draw consistently; (2) when the
scrollbars do draw, sometimes the scrolling is Very Slow; (3) sometimes
gray shows around the tree control.
Does anyone know the correct method for stretching a control to fill a
FormView?
Thanks
Dan Levi
dlevi@hworks.com
Daniel W. Levi -- DLevi@hworks.com
Thursday, March 20, 1997
Several days ago i wrote:
>I 've got a CFormView-derived class with one control, derived from
> CTreeCtrl. I'm looking for behaviour similar to the SQL-Enterpriser
> Manager.
>
> I over-rode the View OnSize() to resize tree control so it occupies the
> whole view window. This is making the tree control redraw itself very
> strangely: (1) the scrollbars are not draw consistently; (2) when the
> scrollbars do draw, sometimes the scrolling is Very Slow; (3) sometimes
> gray shows around the tree control.
>
> Does anyone know the correct method for stretching a control to fill a
> FormView?
One solution (thanks go to Peter Moravek) was to rewrite my view class,
deriving from CView instead of CFormView. Another was, in my override if
OnSize(), to call CView::OnSize() instead of CFormView::OnSize().
The code is
void CCEMView::OnSize(UINT nType, int cx, int cy)
{
// use CView::OnSize, CFormView::OnSize causes scroll bar wierdness
CView::OnSize(nType, cx, cy);
ResizeTreeCtrl();
}
void CCEMView::ResizeTreeCtrl()
{
if (m_tree.m_hWnd != NULL)
{
CRect rCFormView;
GetClientRect( &rCFormView ); // Get view's client rect
m_tree.SetWindowPos( this,
rCFormView.left, rCFormView.top, rCFormView.right, rCFormView.bottom,
SWP_NOZORDER | SWP_SHOWWINDOW
);
}
}
Thanks to all those who commented and proposed solutions.
Dan Levi
dlevi@hworks.com
Become an MFC-L member
| Вернуться в корень Архива
|