From: mp on
"Bob Butler" <noway(a)nospam.ever> wrote in message
news:_2eQn.30194$yx.11535(a)newsfe13.iad...
>
> "mp" <nospam(a)thanks.com> wrote in message
> news:huqv7a$ec6$1(a)news.eternal-september.org...
>> Hi all,
>> I'm building a little form that can have multiple listboxes
....
>> how can i emulate the way windows expands partial text into a little tool
>> tip when you hover a mouse over?
>
> Private Type MakeDWord
> X As Integer
> Y As Integer
> End Type
> Private Const LB_ITEMFROMPOINT = &H1A9
> Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
> (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
> ByRef lParam As Any) As Long
> Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
> (ByRef dest As Any, ByRef src As Any, ByVal kBytes As Long)
>
> Function ListBoxHitTest(ByVal LB As ListBox, _
> ByVal X As Single, ByVal Y As Single) As Long
> Dim uParam As MakeDWord
> Dim lParam As Long
> Dim r As Long
> uParam.X = Me.ScaleX(X, Me.ScaleMode, vbPixels)
> uParam.Y = Me.ScaleY(Y, Me.ScaleMode, vbPixels)
> CopyMemory lParam, uParam.X, 4
> r = SendMessage(LB.hwnd, LB_ITEMFROMPOINT, 0, ByVal lParam)
> ListBoxHitTest = r
> End Function
>
> Private Sub Form_Load()
> Dim X As Long
> For X = 1 To 26
> List1.AddItem String$(30, Chr$(X + 64))
> Next
> End Sub
>
> Private Sub List1_MouseMove(Button As Integer, Shift As Integer, X As
> Single, Y As Single)
> Dim i As Long
> i = ListBoxHitTest(List1, X, Y)
> If i >= 0 And i < List1.ListCount Then
> List1.ToolTipText = List1.List(i)
> Else
> List1.ToolTipText = ""
> End If
> End Sub
>

holyflyinglightningbolts batman!!! that's awesome!!
that would have taken me a year to figure out!!! i knew there must be
someway to do that hittest but sure had no clue how...I didn't even notice
the lb had a built in tooltip property...i'm the eternal newbie...:-)
thank you so much!
mark


From: mp on
obviously Bob's answer solved this riddle nicely!!
so this thread is happily concluded...thanks again BOB!

"mp" <nospam(a)thanks.com> wrote in message
news:hurpsn$r78$1(a)news.eternal-september.org...
>> | Hi all,
>> | I'm building a little form that can have multiple listboxes
>> | listboxes show contents of a selected folder
>> | like a (very rudimentary) group of "windows explorers" on one form
>> | so i can conveniently look at different folders without having to
>> stretch
>> | and position multiple explorer windows.
>> |
>> | since i group multiple listboxes they can be smaller than the filenames
>> | shown.
>> |
>> | how can i emulate the way windows expands partial text into a little
>> tool
>> | tip when you hover a mouse over?
>> |
>> | thanks
>> | mark
>> |
>> |
>>
>>
>
> "Mayayana" <mayayana(a)invalid.nospam> wrote in message
> news:hur0s8$58l$1(a)news.eternal-september.org...
>> The gist of it is fairly simple.
>> There's a sample tooltip class here:
>>
>> http://btmtz.mvps.org/tooltip/
>>
>
> Ok that's a helpful start...easy to add a tool tip to a control...very
> cool.
> now i have to figure how to track where the mouse is in the listbox, over
> what filename, in order to populate the tooltip with the full name of the
> filename that is being truncated by the size of the listbox.
> ...hmmm... i hope i don't have to subclass to do this as i'm totally
> ignorant of how to and dont' know if i have the mental resources to learn
> :-)
> i'm guessing somehow i can use mouse move, figure where the mouse is in
> the list but how the heck to tell exactly what line it's on?
>
> Private Sub List1_MouseMove(Index As Integer, Button As Integer, Shift As
> Integer, X As Single, Y As Single)
> The x and y values are always expressed in terms of the coordinate system
> set by the ScaleHeight, ScaleWidth, ScaleLeft, and ScaleTop properties of
> the object.
>
> ...hmm... so how to figure which item it's over?
>
> End Sub
>
> any ideas?
> thanks
> mark
>
>


From: Bob Butler on

"mp" <nospam(a)thanks.com> wrote in message
news:hurrph$df5$1(a)news.eternal-september.org...
> "Bob Butler" <noway(a)nospam.ever> wrote in message
> news:_2eQn.30194$yx.11535(a)newsfe13.iad...
>>
>> "mp" <nospam(a)thanks.com> wrote in message
>> news:huqv7a$ec6$1(a)news.eternal-september.org...
>>> Hi all,
>>> I'm building a little form that can have multiple listboxes
> ...
>>> how can i emulate the way windows expands partial text into a little
>>> tool tip when you hover a mouse over?
>>
>> Private Type MakeDWord
>> X As Integer
>> Y As Integer
>> End Type
>> Private Const LB_ITEMFROMPOINT = &H1A9
>> Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
>> (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
>> ByRef lParam As Any) As Long
>> Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
>> (ByRef dest As Any, ByRef src As Any, ByVal kBytes As Long)
>>
>> Function ListBoxHitTest(ByVal LB As ListBox, _
>> ByVal X As Single, ByVal Y As Single) As Long
>> Dim uParam As MakeDWord
>> Dim lParam As Long
>> Dim r As Long
>> uParam.X = Me.ScaleX(X, Me.ScaleMode, vbPixels)
>> uParam.Y = Me.ScaleY(Y, Me.ScaleMode, vbPixels)

Bug there... the X & Y are already in pixels regardless of the form's
scalemode

those 2 lines should be:
uParam.X = X / Screen.TwipsPerPixelX
uParam.Y = Y / Screen.TwipsPerPixelY

From: mp on

"Bob Butler" <noway(a)nospam.ever> wrote in message
news:hJeQn.37115$rU6.31197(a)newsfe10.iad...
>
> "mp" <nospam(a)thanks.com> wrote in message
> news:hurrph$df5$1(a)news.eternal-september.org...
>> "Bob Butler" <noway(a)nospam.ever> wrote in message
>> news:_2eQn.30194$yx.11535(a)newsfe13.iad...
>>>
>>> "mp" <nospam(a)thanks.com> wrote in message
>>> news:huqv7a$ec6$1(a)news.eternal-september.org...
>>>> Hi all,
>>>> I'm building a little form that can have multiple listboxes
>> ...
>>>> how can i emulate the way windows expands partial text into a little
>>>> tool tip when you hover a mouse over?
>>>
>>> Private Type MakeDWord
>>> X As Integer
>>> Y As Integer
>>> End Type
>>> Private Const LB_ITEMFROMPOINT = &H1A9
>>> Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
>>> (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
>>> ByRef lParam As Any) As Long
>>> Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
>>> (ByRef dest As Any, ByRef src As Any, ByVal kBytes As Long)
>>>
>>> Function ListBoxHitTest(ByVal LB As ListBox, _
>>> ByVal X As Single, ByVal Y As Single) As Long
>>> Dim uParam As MakeDWord
>>> Dim lParam As Long
>>> Dim r As Long
>>> uParam.X = Me.ScaleX(X, Me.ScaleMode, vbPixels)
>>> uParam.Y = Me.ScaleY(Y, Me.ScaleMode, vbPixels)
>
> Bug there... the X & Y are already in pixels regardless of the form's
> scalemode
>
> those 2 lines should be:
> uParam.X = X / Screen.TwipsPerPixelX
> uParam.Y = Y / Screen.TwipsPerPixelY
>

I can't see a difference in the result. Tried it both ways.
maybe in a specific circumstance it would error?


From: Bob Butler on

"mp" <nospam(a)thanks.com> wrote in message
news:hus6pi$upo$1(a)news.eternal-september.org...
>
> "Bob Butler" <noway(a)nospam.ever> wrote in message
> news:hJeQn.37115$rU6.31197(a)newsfe10.iad...
>>
>> "mp" <nospam(a)thanks.com> wrote in message
>> news:hurrph$df5$1(a)news.eternal-september.org...
>>> "Bob Butler" <noway(a)nospam.ever> wrote in message
>>> news:_2eQn.30194$yx.11535(a)newsfe13.iad...
>>>>
>>>> "mp" <nospam(a)thanks.com> wrote in message
>>>> news:huqv7a$ec6$1(a)news.eternal-september.org...
>>>>> Hi all,
>>>>> I'm building a little form that can have multiple listboxes
>>> ...
>>>>> how can i emulate the way windows expands partial text into a little
>>>>> tool tip when you hover a mouse over?
>>>>
>>>> Private Type MakeDWord
>>>> X As Integer
>>>> Y As Integer
>>>> End Type
>>>> Private Const LB_ITEMFROMPOINT = &H1A9
>>>> Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
>>>> _
>>>> (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
>>>> ByRef lParam As Any) As Long
>>>> Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
>>>> (ByRef dest As Any, ByRef src As Any, ByVal kBytes As Long)
>>>>
>>>> Function ListBoxHitTest(ByVal LB As ListBox, _
>>>> ByVal X As Single, ByVal Y As Single) As Long
>>>> Dim uParam As MakeDWord
>>>> Dim lParam As Long
>>>> Dim r As Long
>>>> uParam.X = Me.ScaleX(X, Me.ScaleMode, vbPixels)
>>>> uParam.Y = Me.ScaleY(Y, Me.ScaleMode, vbPixels)
>>
>> Bug there... the X & Y are already in pixels regardless of the form's
>> scalemode
>>
>> those 2 lines should be:
>> uParam.X = X / Screen.TwipsPerPixelX
>> uParam.Y = Y / Screen.TwipsPerPixelY
>>
>
> I can't see a difference in the result. Tried it both ways.
> maybe in a specific circumstance it would error?

Change the form's scalemode and try it.