I'm trying to override the default selected item painting in a ListView in
Details mode. So, I'm overriding OnPaint and then checking to see which
items are selected and *trying* to draw my own selection border. When I
click around on the three items in my test list control, and examine the
clipping rect that's passed in and compare with the bounds of the item I
just selected, they usually overlap except for the very first item.
So, what I see is that I usually get a paint message with a clipping rect
that includes the previous item *and* the new item. But, when I click on
the first item in the list, the clipping rect does not include the first
item in the list for some reason. (??)
Below is some tracing code from the paint handler. The number in the square
brackets is the index of the item in the list that is marked as selected
when the OnPaint is received. The "Drawing border..." message will only be
generated if there are selected items and specifies the bounds of the
selected item. What confuses me the most is why the first item is excluded
from the clipping region. It seems to me, that if I just clicked on it that
it would need to be repainted. Is this a bug in the .Net framework?
OnPaint received. ClipRect = {X=0,Y=19,Width=120,Height=28}
Drawing border rect:[1] {X=0,Y=33,Width=120,Height=14}
OnPaint received. ClipRect = {X=0,Y=33,Width=120,Height=14}
Drawing border rect:[0] {X=0,Y=19,Width=120,Height=14}
OnPaint received. ClipRect = {X=0,Y=19,Width=120,Height=28}
Drawing border rect:[1] {X=0,Y=33,Width=120,Height=14}
OnPaint received. ClipRect = {X=0,Y=33,Width=120,Height=28}
Drawing border rect:[2] {X=0,Y=47,Width=120,Height=14}
OnPaint received. ClipRect = {X=0,Y=47,Width=120,Height=14}
Drawing border rect:[0] {X=0,Y=19,Width=120,Height=14}
Terry