Discussion:
Programatically Highlighting A Row In A CListCtrl
(too old to reply)
r***@gmail.com
2017-08-16 10:32:02 UTC
Permalink
Thanks, the de-select code is what I was after.

And for what it's worth, the constant 0x000F used above is simply the logical OR of this:

LVIS_SELECTED | LVIS_FOCUSED | LVIS_CUT | LVIS_DROPHILITED
Robert Fritz
2017-08-16 11:19:19 UTC
Permalink
Thanks, the de-select code is what I was after.

And for what it's worth, the constant 0x000F used above is simply the logical OR of this:

LVIS_SELECTED | LVIS_FOCUSED | LVIS_CUT | LVIS_DROPHILITED

and as LVIS_CUT is defined as "The item is marked for a cut-and-paste operation.", unless your implementation requires it (and mine did not), it can be omitted.

In my case I was also using ModifyExtendedStyle(LVS_EX_CHECKBOXES,LVS_EX_CHECKBOXES) which puts a checkbox next to the text label in the first column. And it has the peculiar behavior that you can click the label which will perform the normal selection behavior (LVIS_SELECTED | LVIS_FOCUSED | LVIS_DROPHILITED), but if you click just the check box, it does not. That is, if you select any text in Row 1 it'll be highlighted as you'd expect. But if you then toggle the check box in Row 2, Row 1 remains selected as you handle the LVN_ITEMCHANGED message for Row 2. And in my implementation, I wanted to emulate the standard Select / Multi-select behavior (using GetKeyState(VK_SHIFT) and GetKeyState(VK_CONTROL)) in addition to the check box. And I should probably note that if you select the text label next to the check box, hitting the space bar toggles the check box, an artifact from long ago.
Robert Fritz
2017-08-16 11:29:10 UTC
Permalink
Thanks. I was searching for the de-select code.

My implementation uses the extended style LVS_EX_CHECKBOXES which puts a checkbox next to the text label in the first column.

The checkbox alters the normal selection behavior in that toggling the check-box on any row does not automatically select & focus that row. And I wanted to emulate that behavior, including GetKeyState(VK_SHIFT) and GetKeyState(VK_CONTROL).

Incidentally, the x000F used above is the logical OR of:
LVIS_SELECTED | LVIS_FOCUSED | LVIS_CUT | LVIS_DROPHILITED

So if your implementation doesn't require LVIS_CUT, defined as "The item is marked for a cut-and-paste operation", you can omit that mask.
Loading...