How to resize the CListCtrl attached in a CListView?

Hi all...

I have a CListView view in my SDI application... the problem is that when the main window is maximized, the attached CListCtrl is resized to occupy the whole view area (and that is what I want).. but.. when the main window is resized (to normal state, for example), and after resizing columns widths, it seems that the CListCtrl isn't resized so the horizontal scroll bar is shown... How can I avoid that?

This is my ClistView OnSize event

// CTransView message handlers

void CTransView::OnSize(UINT nType, int cx, int cy)
      CListView::OnSize(nType, cx, cy);
      CRect rect;
      CListCtrlEx& ListaMarcas = (CListCtrlEx&)GetListCtrl();
      ListaMarcas.SetColumnWidth(0, 13*rect.Width()/100);
      ListaMarcas.SetColumnWidth(1, rect.Width()/5);
      ListaMarcas.SetColumnWidth(2, rect.Width()/5);
      ListaMarcas.SetColumnWidth(3, rect.Width()/5);
      ListaMarcas.SetColumnWidth(4, 27*rect.Width()/100);

Where CListCtrlEx is a customized CListCtrl.

I hope you can help me...

Thanks a lot in advance...

Who is Participating?
RONSLOWConnect With a Mentor Commented:
Try using GetClientRect instead of GetWindowRect.  GetWindowRect includes any non-client area (eg borders etc).
skelAuthor Commented:
Thanks... I'll try it when I get answer for my another question concerning this fact....

But.. you said that I can use GetClientRect instead of GetWindowRect.... I think that isn't the problem since the column windth change accordingly to the new size, what is OK... the problem is the width of the whole control which keeps its size without resizing accordingly to its columns width..

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.