Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Highlight a CListCtrl Header Column ?

708 views
Skip to first unread message

Danny Pressley

unread,
Jan 4, 2000, 3:00:00 AM1/4/00
to
I have a CListCtrl derived class that allows sorting on columns when
in report view mode. Without doing an owner drawn CListCtrl, is there
any way to highlight or make an individual column header look
different. This will allow a visible distinction to the user for which
column the control is being sorted by.

Thanks for any info
Danny

Scot T Brennecke

unread,
Jan 5, 2000, 3:00:00 AM1/5/00
to
Look at CListCtrl::GetHeaderCtrl() and CHeaderCtrl::SetImageList and SetItem.
You can display images on the column headers.

Chip Calvert

unread,
Jan 5, 2000, 3:00:00 AM1/5/00
to
On Wed, 05 Jan 2000 07:27:44 -0600, Scot T Brennecke
<mar...@airmail.net> wrote:

>Look at CListCtrl::GetHeaderCtrl() and CHeaderCtrl::SetImageList and SetItem.
>You can display images on the column headers.

Note that the list control will not draw these images transparently,
so you'd bettern make them square or make the background color light
gray and cross your fingers that all of your users use standard
windows colors. For more info on this method, see:

http://www.codeguru.com/listview/image_in_header.shtml
http://www.codeguru.com/listview/imagelist_with_header.shtml

For an alternative, see a post I made today to
comp.os.ms-windows.programmer.win32 and
comp.os.ms-windows.programmer.tool.mfc with the subject "Re: Listview
problem". It does require custom drawing however.

>Danny Pressley wrote:
>
>> I have a CListCtrl derived class that allows sorting on columns when
>> in report view mode. Without doing an owner drawn CListCtrl, is there
>> any way to highlight or make an individual column header look
>> different. This will allow a visible distinction to the user for which
>> column the control is being sorted by.
>>
>> Thanks for any info
>> Danny

--
Chip
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
"Make it idiot-proof and someone will make a better idiot."
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Danny Pressley

unread,
Jan 5, 2000, 3:00:00 AM1/5/00
to
I've already tried that. Some of the columns description text in the header don't
leave enough room for an image to be on it also (the text gets chopped when an
image is added), and I'm unable to widen the columns to make enough room.
Otherwise, the image of an up or down arrow on the active sorting column would do
it.

Thanks any ways
Danny


Scot T Brennecke wrote:

> Look at CListCtrl::GetHeaderCtrl() and CHeaderCtrl::SetImageList and SetItem.
> You can display images on the column headers.
>

Chip Calvert

unread,
Jan 11, 2000, 3:00:00 AM1/11/00
to
On Wed, 05 Jan 2000 16:16:48 -0500, Danny Pressley
<remove_d...@controltechnology.com> wrote:

>I've already tried that. Some of the columns description text in the header don't
>leave enough room for an image to be on it also (the text gets chopped when an
>image is added), and I'm unable to widen the columns to make enough room.
>Otherwise, the image of an up or down arrow on the active sorting column would do
>it.

You stated in your original post that you don't want to make the list
control owner-drawn. What about the header control? You could fill
the background using a different color or make the text underlined
using an owner-drawn header control.

Danny Pressley

unread,
Jan 12, 2000, 3:00:00 AM1/12/00
to
After doing what research I could and seeing the responses from this thread, it looks
like the only valid solution is to make an owner drawn control.

I was able to us the below line of code to make a minor visible column identifier. It
makes the left side of the column header turn to a dark blue color. But its definitely
not the correct solution.

I put this line of code in my sorting algorithm.
((CHeaderCtrl*)MyListCtrl.GetDlgItem(0))->SetHotDivider(nCol);

Thanks again
Danny

Chip Calvert

unread,
Jan 12, 2000, 3:00:00 AM1/12/00
to
On Wed, 12 Jan 2000 08:31:38 -0500, Danny Pressley
<remove_d...@controltechnology.com> wrote:

>After doing what research I could and seeing the responses from this thread, it looks
>like the only valid solution is to make an owner drawn control.
>
>I was able to us the below line of code to make a minor visible column identifier. It
>makes the left side of the column header turn to a dark blue color. But its definitely
>not the correct solution.
>
>I put this line of code in my sorting algorithm.
> ((CHeaderCtrl*)MyListCtrl.GetDlgItem(0))->SetHotDivider(nCol);

I think that making the background a different color, changing the
font or maybe underlining the column title are all good ways to
indicate the sort direction. You can do all of those by subclassing
the header control and making it owner drawn.

For an example of this, see
http://www.codeguru.com/listview/indicating_sort_order.shtml. This
article shows how to indicate the sort using an owner-drawn header
that displays a triangle in the sorted column header. However, you
can certainly adapt it easily to indicate the sorted column using one
of the methods I mentioned above.

Danny Pressley

unread,
Jan 13, 2000, 3:00:00 AM1/13/00
to
I took a look at the code and it seems to be straight forward enough.

Thanks for the advice and the URL.

Danny

0 new messages