How enable CListCtrl to highligh icon background

drjackool 956 Reputation points
2021-11-14T18:23:35.53+00:00

Hi
How to force change list view control to highlight icon background when an item is selected in report view?

lvcustomdraw3.gif
thanks

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,139 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,739 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Castorix31 85,451 Reputation points
    2021-11-15T11:12:41.187+00:00

    You just draw the background + icon in CDDS_ITEMPOSTPAINT when the row is selected :

    149360-listview-selectedicon.gif

    2 people found this answer helpful.
    0 comments No comments

  2. Carrie Boyer 76 Reputation points
    2021-11-14T18:28:13.953+00:00

    See if this is worth trying:

    1- Derive a class from CListCtrl.

    2- Include a data member of type CButton array, with as many elements as necessary for your view.

    3- Let the CButton's C++ objects be created (but not the GDI objects).

    4- Override the DrawItem() virtual function.

    5- Every first time this override is called for each view's element, you, then, create the GDI object for this specific element (see 6 and 7).

    6- Use the CListCtrl's window as CButton's parent window.

    7- Once created never more let it be recreated.

    8- Deal with button's click inside each CButton class.

    --please don't forget to upvote and Accept as answer if the reply is helpful--


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.