Simplest way to change listview and treeview colours
Asked Answered
S

4

5

I'm trying to find a simple way to change the colour of the text and background in listview and treeview controls in WTL or plain Win32 code.

I really don't want to have to implement full owner drawing for these controls, simply change the colours used.

I want to make sure that the images are still drawn with proper transparency.

Any suggestions?

Sallie answered 5/9, 2008 at 10:54 Comment(0)
H
3

Have a look at the following macros:

ListView_SetBkColor
ListView_SetTextColor

TreeView_SetBkColor
TreeView_SetTextColor

Hardcore answered 5/9, 2008 at 11:38 Comment(0)
O
2

There are also appropriate methods of the CListViewCtrl and CTreeViewCtrl wrapper classes:

  • GetBkColor
  • SetBkColor
Orthodox answered 8/9, 2008 at 7:3 Comment(0)
Z
2

You may also want to take a look at WTL's CCustomDraw::OnItemPrePaint (that's if you need to control the drawing of individual items)

A good article that describes this process is here

Zela answered 8/9, 2008 at 8:35 Comment(0)
I
0

It's been a while since I've use the win32 API directly, but I believe that if you handle the WM_ERASEBACKGROUND message for your control, you can use FillRect() in your handler to paint the background using whatever color you like.

Idaliaidalina answered 5/9, 2008 at 11:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.