On Oct 11, 2006 5:35 PM, Tim Hare wrote:
> Carlos,
>
> I'd like the same functionality (I'm on Windows, too), but
> it seems like the helptag just plain works wrong. Unless
> I'm missing something, it looks like the helptag appears at
> a set interval after the mouse enters the control, NOT when
> the mouse stops moving and "hovers" over the control. So it
> doesn't really help to just change the help tag.
>
> How did you address this? Would you share your solution
> with me? Either on list, or off list if you desire.
Sure, here's the code I'm currently using.
To display an HelpTag for each cell with its content use the
following:
Sub MouseMove(X As Integer, Y As Integer)
Dim row As Integer = Me.RowFromXY( x, y )
Dim column As Integer = Me.ColumnFromXY (x, y )
If row >= 0 And column >= 0 Then
Dim s As string = Me.Cell(row, column)
If Me.HelpTag <> s Then Me.HelpTag = s
Else
Me.HelpTag = ""
End If
End Sub
Sub MouseExit()
Me.HelpTag = ""
End Sub
Noticed that on MouseMove event I only set the HelpTag if is different
from the current HelpTag - this is the only way I found in order to
correctly display the HelpTag using the MouseMove because if you
change it while the mouse is moving it will never display. So, with
this check it works fine.
As for displaying the HelpTag *only* when the text is truncated it
requires some additional code to check if text is truncated or not. So
the working code that I currently have is:
Sub MouseMove(X As Integer, Y As Integer)
Dim row As Integer = Me.RowFromXY( x, y )
Dim column As Integer = Me.ColumnFromXY (x, y )
If row >= 0 And column >= 0 Then
If IsTextTruncated(row, column) Then
Dim s As string = Me.Cell(row, column)
If Me.HelpTag <> s Then Me.HelpTag = s
Else
Me.HelpTag = ""
End If
Else
Me.HelpTag = ""
End If
End Sub
Sub MouseExit()
Me.HelpTag = ""
End Sub
Function IsTextTruncated(row As Integer, column As Integer) As Boolean
Dim textWidth As Integer
Dim colWidth As Integer
Dim p As Picture = New Picture(1, 1, 32)
p.Graphics.TextFont = Me.TextFont
p.Graphics.TextSize = Me.TextSize
textWidth = p.Graphics.StringWidth( Me.Cell(row,column) ) + 3 // 3px
offset given
colWidth = Me.Column(column).WidthActual
If textWidth >= colWidth Then Return True
End Function
It's working fine on Win2K - did not text it yet on XP but I presume
it works fine - maybe the 3px offset I give for textWidth might need a
correction.
HTH
Carlos
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>