by wuguru01 (1 Submission)
Category: Miscellaneous
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Thu 23rd May 2002
Date Added: Mon 8th February 2021
Rating:
(1 Votes)
A multi-line tooltiptext Example. No API Calls, two very small function. Easy to incorporate into any program. Very well documented.
'
'Instructions for Use:
'You will need a TextBox named TxtToolTip Don't forget your
'Textbox should be multi-line, and after you have created your
'textbox, be sure you right click the textbox and click bring to
'If you don't, it may end up behind other controls at runtime.
'Also tabstop should be set to false. In my example I set
'the background color of the textbox to tooltiptext.
'
'Now the disclaimer:
'This is not idiot proof code, I spent longer on the documentation
'than the codeing. This is just an example, you paid nothing
'and got free code. I am not responsible for what you do
'with it, and I owe you nothing if for some reason it fails
'to meet your expectations. You may include it as is or altered
'in any way you see fit. I don't expect my name in your code
'any more than I would put yours in mine. Its an example
'I put together in about 10 minutes.
'
'This code proudly boasts, no api calls. And the documentation
'is longer than the code.
'
'There are only two functions, to MrToolTip.
'1. MrToolTip(MyControl As Control, MyString As String)
' Syntax: MrToolTip ControlName, Text
'2. MrToolTipReset()
' Syntax: MrToolTipReset
'To Run the sample included you will need a label named label1
'and a command button, oddly named command1.
'place them anywhere on the form, and run the app.
'
'Have fun!
'
'A Multi-Line ToolTip Example
'
'by: Christopher D. Manns
'------------------ MrToolTip Starts Here ----------------
Public Function MrToolTip(MyControl As Control, MyString As String)
'Tip is displayed where there is more room.
TxtToolTip.Visible = True
If MyControl.Left + MyControl.Width + TxtToolTip.Width < Me.Width - MyControl.Left + TxtToolTip.Width Then
TxtToolTip.Move MyControl.Left + MyControl.Width, MyControl.Top
Else
TxtToolTip.Move MyControl.Left - TxtToolTip.Width, MyControl.Top
End If
TxtToolTip.Text = MyString
End Function
Private Function MrToolTipReset()
'Hide the tool tip text box.
TxtToolTip.Visible = False
TxtToolTip.Text = ""
End Function
'------ Everything below an Example Using MrToolTip -------
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'An Example of how to call MrToolTip, you can call MrToolTip from
'MouseMove Event of any control.
MrToolTip Command1, "This is an example of " & _
"MrToolTip. Can't beat a Multi-Line Tool Tip"
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'Unless you want a tooltip for the form, clear it and hide.
MrToolTipReset
End Sub
Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'Another Example calling MrToolTip, this time from a label.
'Note: MrToolTip will accept any input accepted by a textbox.
MrToolTip Label1, "This is a label test of my MrToolTip Routine" & vbCrLf & "What do you think about it"
End Sub
Private Sub TxtToolTip_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'User has moved from active control.
MrToolTipReset
End Sub
No comments have been posted about A multi-line tooltiptext Example. No API Calls, two very small function. Easy to incorporate into a. Why not be the first to post a comment about A multi-line tooltiptext Example. No API Calls, two very small function. Easy to incorporate into a.