hi all,
i wonder if someone has done it before,
i try to check if my mouse is over a part of a string in a list view,
i have no problem determine if i am at the currect column and row, but i wanna make my code work ONLY if i hover my mouse in a part of the string that is at the row & column i hovered on.

for example,
if my string is: "Win32ASM IS COOL"
and i hover my mouse over this text, i want my code to execute only of my mouse is really hovering over *COOL* part of the string.

thanks all
Posted on 2004-11-15 17:11:34 by wizzra
I suppose this could be done using some hit-testing to determine the row/column, and calculations with the help of GetTextExtentPoint32().

Alternatively, you might want to explore the Windows Accessibility API. I think it's much more complex than the first option, though.
Posted on 2004-11-15 17:35:30 by death
thanks (toda!) Death,

i'v managed to use GetTextExtentPoint32() .

in this way:

1. calculate the offset of the column we want to over on (loop all pre columns and add the width of them, this will give you the start offset of the column you want to search in)

2. store & calculate the entire string that your subString located at with: GetTextExtentPoint32, hSize.cx contains the width.

3. calculate the subString in which you want to hover on with: GetTextExtentPoint32, hSize.cx contains the width.

4. get the mouse pos: GetCursorPos and than ScreenToClient functions

5. calculate and check if we are hovering over the subString:

note: we use a 20pixel padding +- for the letters because of the font used.

this is abstract code:

MousePos = MOUSEPOINT.X-ColumnOffset+20

if ( ( MousePos>(WholeTextWidth-SubStringWidth+20) ) AND
(MousePos<WholeTextWidth) )

Posted on 2004-11-15 19:59:38 by wizzra