devxlogo

Display Tooltips

Display Tooltips

You can easily duplicate the tooltips that appear when you float the mouse over a button in Microsoft’s products. This code displays the tooltip in the lower right-hand corner of the control (normally a button):

 ' xTip: string to display as the tip' xCtrl: control you want the tip to show for.' xTipControl: control being used to display ' the tip (an SSPanel)Public Sub ShowTip(xTip As String, xCtrl As _	Control, xTipControl As Control)	xTipControl.Left = xCtrl.Left + xCtrl.Width	xTipControl.Top = xCtrl.Top + xCtrl.Height	xTipControl.Caption = xTip	xTipControl.Visible = TrueEnd Sub

This code hides the tooltip:

 ' xTipControl : control which is being used to ' display the tip.Public Sub HideTip(xTipControl As Control)	xTipControl.Visible = FalseEnd Sub

Place the ShowTip function in the MouseMove event of the control(s) for which you want to display a tip. Place the HideTip function in the other control(s) for which you don’t want to display a tip:

 Sub Command1_MouseMove (Button As Integer, _	Shift As Integer, X As Single, Y As Single)	ShowTip "Command1", Command1, SSPanel1End SubSub Command2_MouseMove (Button As Integer, _	Shift As Integer, X As Single, Y As Single)	ShowTip "Command2", Command2, SSPanel1End SubSub Form_MouseMove (Button As Integer, _	Shift As Integer, X As Single, Y As Single)'No tooltip for form	HideTip Text1End Sub

devx-admin

Share the Post: