CListCtrl row header  
Author Message
Farid_Z





PostPosted: Visual C++ General, CListCtrl row header Top

Does anybody know how to make a row header for CListCtrl This would be analogous to a column header, it would not move when user scrolls the list horizontally. I have tried to simulate such a header by drawing in the non-client area on the left of each row.
1. Intercept WM_NCCALCSIZE and shrink client area by row header width
2. Use WM_NCPAINT to draw the row header

Problem I ran into is that the standard window horizontal scrollbar is positioned/sized using the client area width leaving a gap on the left of the scrollbar. I haven't been able to find out how to reposition/size the window standard horizontal scrollbar ( it't not a real scrollbar, rather a "virtual" scrollbar that is drawn by Windows when the non-client area is drawn ).

Any ideas




Visual C++11  
 
 
Simple Samples





PostPosted: Visual C++ General, CListCtrl row header Top

As you have determined, the listview control (CListCtrl) does not offer that feature. There are probably samples in sites such as CodeProject and CodeGuru. You might want to abandon the CListCtrl and use a grid control of some type instead. You might find something closer to what you want among the controls provided with VS. There are also grid samples in the other sites. If you don't need update capability for the data, then the grid controls could be easier and more powerful.

 
 
Viorel.





PostPosted: Visual C++ General, CListCtrl row header Top

[...]
Any ideas

Maybe you should put your first column in an additional CListCtrl, having no scroll bars and positioned at the left side of your main list control Its scroll position should be synchronised programmatically with the position of main list control. I hope this makes sense.


 
 
Farid_Z





PostPosted: Visual C++ General, CListCtrl row header Top

Using a separate ctrl for the row header I end up with the same problem. When the CListCtrl horizontal scrollbar appears you would have a gap between the bottom of the row headers and the left side of the horizontal scrollbar. Drawing in the non-client area accomplishes the same thing without the need for another list ctrl. But both approaches have the same visual issue with a gap to the left of the horizontal scrollbar. If only I could tell the window to reposition the standard horizontal scrollbar to start at the left of the client area to cover the gap, then all is good.

 
 
Damien Watkins - MSFT





PostPosted: Visual C++ General, CListCtrl row header Top

Hello

The more appropriate place for your question is probably the MFC newsgroup: http://msdn.microsoft.com/newsgroups/default.aspx dg=microsoft.public.vc.mfc&lang=en&cr=US

Thanks

Damien



 
 
Farid_Z





PostPosted: Visual C++ General, CListCtrl row header Top

Don't be alarmed by the MFC moniker, the MFC class is just a wrapper for the SysListView32 common control, that is used everywhere in Windows ( detail list in File Explorer, File Open dialog, etc ). I am just trying to find out how to implement a simple row header for this control. This is a rather simple functionality for such a widely used control. Can anybody help
 
 
Simple Samples





PostPosted: Visual C++ General, CListCtrl row header Top

Don't be alarmed by the MFC moniker, the MFC class is just a wrapper for the SysListView32 common control, that is used everywhere in Windows ( detail list in File Explorer, File Open dialog, etc ). I am just trying to find out how to implement a simple row header for this control. This is a rather simple functionality for such a widely used control. Can anybody help
Using your logic, this question is a Windows programming question, which makes it even more off-topic for this forum. Note that Damien Watkins is a Microsoft person, which means that Damien knows what MFC is and is expressing Microsoft's intent for this forum.

When I first learned MFC, the internet was not available to get answers so conveniently. There are samples available with MFC of uses of CListCtrl. Search the MSDN for keywords such as CHeaderCtrl, CListCtrl and InsertColumn. Also search the MFC samples. Also use the Community menu in VS 2005 to find many other sites and forums.



 
 
Simple Samples





PostPosted: Visual C++ General, CListCtrl row header Top

Does anybody know how to make a row header for CListCtrl
That is not easy. Elsewhere you say it is easy, but it is not easy. Others have tried. There are probably samples of success or partial success in other sites and you should use them if you can. Otherwise don't use a CListCtril, the Windows listview was not designed with that as a requirement.

 
 
Damien Watkins - MSFT





PostPosted: Visual C++ General, CListCtrl row header Top

Hello

Ok, if it is a Win32 question then the more appropriate place for your question is probably one of the Win32 newsgroups: http://msdn.microsoft.com/newsgroups/topic.aspx url=/MSDN-FILES/028/201/015/topic.xml

OTP

The reason we try and point you to the right place to ask your question is so that you will get an answer.

Thanks

Damien