StateImage&HitTestDetails

The place for threads about TimoSoft ExplorerListView.
Post Reply
User avatar
Mex
Captain
Posts: 130
Joined: 24 Sep 2009, 19:47

StateImage&HitTestDetails

Post by Mex »

Hi,

This time, I think, I found a real bug :)
Listview MouseUp and MouseDownEvents
When I click on stateimage (Windows 7 and Up) hitTestDetails returns 67108928 &h4000040 instead of 64 &H40 and also other constants are different.
Clicking on itemlabel returns 67108868 and item returns 4 instead of 70

Any ideas?

Regards
Meelis
User avatar
TiKu
Administrator
Administrator
Posts: 832
Joined: 28 Sep 2004, 21:10
Location: München
Contact:

Re: StateImage&HitTestDetails

Post by TiKu »

Hi,

I'm afraid you didn't find a bug. ;) I think you missed that the hit-test codes are not mutually exclusive, but can be combined.

&H4000040 is the result of (&H4000000 Or &H40). &H4000000 is htContent, and &H40 is htItemStateImage. So the hit point lies within the item's content as well as within the item's state image - and this is where you clicked. The flag htContent is new for Windows Vista and up. Microsoft has defined the state image to be part of the item's content.

&H4000004 is the result of (&H4000000 Or &H4). &H4 is htItemLabel. So the hit point lies within the item's content as well as within the item's label - and this is where you clicked.

I suppose with 70 you mean htItem (&H46)? Well, this one is the combination (binary Or) of htItemIcon, htItemLabel, and htItemStateImage (&H2 Or &H4 Or &H40). You can use htItem if you're not interested in the exact part of an item that has been hit. So instead of:

Code: Select all

Dim bHitItem As Boolean

bHitItem = False
If hitTestDetails And htItemIcon Then
  bHitItem = True
ElseIf hitTestDetails And htItemLabel Then
  bHitItem = True
ElseIf hitTestDetails And htItemStateImage Then
  bHitItem = True
End If

If bHitItem Then ...
you can just write:

Code: Select all

Dim bHitItem As Boolean

bHitItem = False
If hitTestDetails And htItem Then
  bHitItem = True
End If

If bHitItem Then ...
This would also work (but is not as easy to read):

Code: Select all

Dim bHitItem As Boolean

bHitItem = False
If hitTestDetails And (htItemIcon Or htItemLabel Or htItemStateImage) Then
  bHitItem = True
End If

If bHitItem Then ...
Regards
TiKu
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
User avatar
Mex
Captain
Posts: 130
Joined: 24 Sep 2009, 19:47

Re: StateImage&HitTestDetails

Post by Mex »

And thank you again!

At least, all others can learn from my mistakes and stupid questions :D


Regards
Meelis
Post Reply