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

Drawing the header of a list control

322 views
Skip to first unread message

Stephen Oakes

unread,
Feb 22, 1999, 3:00:00 AM2/22/99
to
Is it possible to have control over the drawing of the header of a list
control? I have created a list control (CListCtrl in MFC) with the
LVS_OWNERDRAWFIXED style, which allows me to draw the items in the list
box, but not for its header.

--
Stephen Oakes Stephe...@dbce.csiro.au
CSIRO Division of Building, Construction and Engineering
PO Box 56, Highett, Victoria, 3190, Australia.
Tel: +61 3 92526000 Mobile: +61 41 605 9408
Fax: +61 3 92526249

ste...@dbce.csiro.au

unread,
Feb 24, 1999, 3:00:00 AM2/24/99
to

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own

Chip Calvert

unread,
Mar 16, 1999, 3:00:00 AM3/16/99
to
Stephen,

On Mon, 22 Feb 1999 14:30:56 +1000, Stephen Oakes
<Stephe...@dbce.csiro.au> wrote:

>Is it possible to have control over the drawing of the header of a list
>control? I have created a list control (CListCtrl in MFC) with the
>LVS_OWNERDRAWFIXED style, which allows me to draw the items in the list
>box, but not for its header.

Yes. You must get the individual column header using
CHeaderCtrl::GetItem, and set it to "owner drawn":

// Header item
HD_ITEM hditem;
// We want the formatting info
hditem.mask = HDI_FORMAT;
// Get it
GetItem(Col, &hditem );
// Set it to owner drawn
hditem.fmt |= HDF_OWNERDRAW;
// Set the new info
SetItem(Col, &hditem );

In your header class, you must override CHeaderCtrl::DrawItem() to do
your custom drawing.

For an example of this, see
http://www.codeguru.com/listview/indicating_sort_order.shtml.


Chip

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

Remove NO and SPAM from my email address.

Stephe...@dbce.csiro.au

unread,
Mar 18, 1999, 3:00:00 AM3/18/99
to
NOcbcal...@erols.com (Chip Calvert) wrote:
> >Is it possible to have control over the drawing of the header of a list
> >control?

> Yes. You must get the individual column header using


> CHeaderCtrl::GetItem, and set it to "owner drawn":

That works, but there is still a problem. Even though that gives
you control of drawing individual items, the header control still
draws its own lines between items, and other peripheral bits.
This means that if you want to (for example) remove the dividing
lines or draw them in a different colour, you're stuck.

The solution is to subclass the header control, and handle the
WM_PAINT message yourself. This gives you complete control over
drawing the header. If anyone wants more information, just ask.

0 new messages