--
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
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
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.
> 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.