listviews in win32

by oBelIX

*STATUTORY WARNING*

This is a highly specific and technical post. You may get bored out of your skulls.

——————————————————-

Recently have worked a little with listview controls in win32 …

  • In icon mode listviews tend to chop off the first pixel with LVS_EX_BORDERSELECT enabled. Dunno why, seems like a bug.
  • In icon mode if you want to display checkboxes next to the items with BORDERSELECT enabled then you are in trouble. THe checkbox is drawn so close to the icon that the border overlaps it and it looks ugly. So, create a state image list and add it to the listview with two icons of a checked and unchecked state, leaving enough space around the right for the line of the BORDERSELECT to draw over 😀
  • IF you enable flat headers by changing the style of the header to style & (~HDS_BUTTONS) then you wont get LVN_COLUMNCLICK notifications
  • TO change the background colour of listview headers put a custom draw header. Subclass the listview and in the OnNotify handler look for NM_CUSTOMDRAW. There in CDDS_ITEMPREPAINT put in a SetBkCOlor(<hdc>, <color>) to set the background colour of the listview

Hopefully this helps some poor soul when he is trying to get listviews to work well. Mostly, I spent a heckuva lot of time on google looking for the above issues. 

—————————————————

PS1 – got a lot of work

PS2 – oblivion rocks. it simply does 

Advertisement