Valhalla Legends Forums Archive | General Programming | Multiline ToolTipText

AuthorMessageTime
Inner
Ok, the multiline and everything works until i scroll down. It just likes goes backwards or someting, would anyone know the problem?
May 23, 2004, 1:24 AM
Lobo.id
Double posting will not get you any faster help. Show some code.
May 23, 2004, 2:03 AM
Inner
I didn't mean to, i didn't know it was moved. =/

[code]Private Sub MakeToolTip(Item As Integer)
If Item > users.ListItems.Count Or Item = 0 Then Exit Sub
Set ToolTip = New clsToolTip
With ToolTip

'Set the handle of the listview
.HwndParentControl = users.hWnd

'Set the tooltip text, which is stored in the tag of the listview
.Text = users.ListItems.Item(Item).Tag

'Set the title of the tooltip, leave blank if you don't want it
.Title = users.ListItems.Item(Item).Text

'Sets the style of the tooltip, Balloon is another option (TTSBalloon)
.Style = TTSBalloon

'Sets the background color of the tooltip
.BackColor = &H80000018

'Sets the forecolor of the tooltip
.ForeColor = vbBlack

'Makes the tooltip with the desired Settings
Call .Create
End With
End Sub

Private Sub users_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Call MakeToolTip(CInt(y / 220))
End Sub

Public Function Create() As Boolean

On Error GoTo CreateError

Dim lpRect As RECT
Dim lWinStyle As Long

If lngHwnd <> 0 Then DestroyWindow lngHwnd

lWinStyle = TTS_ALWAYSTIP Or TTS_NOPREFIX

'create baloon style if desired
If Me.Style = TTBalloon Then lWinStyle = lWinStyle Or TTS_BALLOON

'the parent control has to have been set first
If Me.HwndParentControl <> 0 Then
lngHwnd = CreateWindowEx(0&, TOOLTIPS_CLASSA, vbNullString, lWinStyle, _
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, _
Me.HwndParentControl, 0&, App.hInstance, 0&)

'make our tooltip window a "topmost" window
SetWindowPos lngHwnd, HWND_TOPMOST, 0&, 0&, 0&, 0&, SWP_NOACTIVATE Or SWP_NOSIZE Or SWP_NOMOVE

'get the rect of the parent control
GetClientRect Me.HwndParentControl, lpRect

'now set our tooltip info structure
With mtypToolInfo
'if we want it centered, then set that flag
If Me.Centered = True Then
.lFlags = TTF_SUBCLASS Or TTF_CENTERTIP
Else
.lFlags = TTF_SUBCLASS
End If

'set the hwnd prop to our parent control's hwnd
.lHwnd = Me.HwndParentControl
.lId = 0
.hInstance = App.hInstance
.lpStr = Me.Text
.lpRect = lpRect
End With

'add the tooltip structure
SendMessage lngHwnd, TTM_ADDTOOLA, 0&, mtypToolInfo

'if we want a title or we want an icon
If Title <> vbNullString Then
SendMessage lngHwnd, TTM_SETTITLE, 0, ByVal Title
End If

'Goes all black if you set it to the standard colours
If ForeColor <> FORE_COLOUR Then
SendMessage lngHwnd, TTM_SETTIPTEXTCOLOR, ForeColor, 0& 'Set the ForeColor
End If
If BackColor <> BACK_COLOUR Then
SendMessage lngHwnd, TTM_SETTIPBKCOLOR, BackColor, 0& 'Set the BackColor
End If
If MultiLine = True Then
SendMessage lngHwnd, TTM_SETMAXTIPWIDTH, 0&, 0 'Set to multiline
End If
End If

Create = True 'All went well!
CreateExit:
On Error Resume Next
Exit Function
CreateError:
Create = False 'Failed!
Resume CreateExit
End Function[/code]

Edit (Grok): added code tags.
May 23, 2004, 3:16 AM
hismajesty
Use the code tags. :)
May 23, 2004, 3:37 AM
UserLoser.
Should do something like...:
[code]
Dim lvwHitTestInfo As LVHITTESTINFO
Dim dwItemIndex As Long
If (lvwUsers.ListItems.Count = 0) Then Exit Sub
With lvwHitTestInfo
.pt.X = (X / Screen.TwipsPerPixelX)
.pt.Y = (Y / Screen.TwipsPerPixelY)
End With
dwItemIndex = SendMessage(lvwUsers.hWnd, LVM_HITTEST, 0&, lvwHitTestInfo) + 1
[/code]
Under your MouseMove

Then...:
[code]
Call MakeToolTip(dwItemIndex)
[/code]

But make sure to destroy the old window (if it exists) before creating a new one
May 23, 2004, 3:56 AM
Inner
Thankyou UserLoser, i got it working fully, and thanks to everyone else for the support.
May 23, 2004, 9:28 PM
Grok
[quote author=Inner link=board=5;threadid=6919;start=0#msg61422 date=1085347712]
Thankyou UserLoser, i got it working fully, and thanks to everyone else for the support.
[/quote]

EXPLAIN! How did yo uget it working fully? Maybe someone can learn from what you did!

Help make this forum better by posting the answer if someone else didn't post it already.
May 24, 2004, 1:02 AM
BaDDBLooD
yes.. i need to know how to do this ;[
May 26, 2004, 10:11 PM
UserLoser.
[quote author=BaDDBLooD link=board=5;threadid=6919;start=0#msg62030 date=1085609508]
yes.. i need to know how to do this ;[
[/quote]

Looks like all the code posted above will allow you to do this
May 26, 2004, 10:30 PM
Flame
There's a few tutorials on PSCode which show how to actually make the tooltip which are helpful. As far as applying the tooltip to a listview, the code UserLoser posted shows exactly how it is done, except for the LVHITTESTINFO, which can be found in This document which I found off of CodeGuru not long ago. The article basically shows every step to making these tooltips.
May 26, 2004, 11:55 PM
Grok
My point was that after posting a problem and eventually arriving at the solution, that solution should be obviously posted, as in:

[quote]Thankyou UserLoser, i got it working fully, and thanks to everyone else for the support. [color=yellow]WHAT WORKED WAS .... blah blah blah [/color][/quote]

This affords everyone who searches the forums in the future, looking to solve the same problem, they will find the answer clearly pointed out to them.
May 27, 2004, 12:33 AM

Search