0

Say I have a Windows ListView with two columns then I can get the Rec of the row with LVM_GETITEMRECT but that Rec does not include the area of the ListView not covered by a column, how do I determine this rectangle area so I can draw in it?

enter image description here

In the picture the area I want is the blue highlighting to the right that has no column, this is basically just to have full row selection looking like its full row.

Col_Blimp
  • 779
  • 2
  • 8
  • 26

1 Answers1

1

Once you obtain the row's RECT, simply change its right field to be the same value as the width of the ListView's client area.

RECT rectRow;
ListView_GetItemRect(hListView, iRow, &rectRow, LVIR_BOUNDS);

RECT rectCli;
GetClientRect(hListView, &rectCli);

rectRow.right = (rectCli.right - rectCli.left);
Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • Thanks, you know this does exactly what I want but my code for redrawing the non row area is on the LVN_ITEMCHANGED event, cant use LVN_ITEMCHANGING because of owner data, and its causing a bit of a lag where the row gets de-highlighted then the newly selected row highlighted then the non row area de-highlighted then highlighted, you wouldn't happen to know the correct event to draw the non row area? – Col_Blimp May 25 '14 at 09:58
  • `LVN_ITEMCHANG(ING/ED)` are not drawing events. You should be drawing everything in the `NM_CUSTOMDRAW` event only. If you need to trigger a redraw when something changes, use `LVM_REDRAWITEMS`. – Remy Lebeau May 25 '14 at 17:22