| Skype: | TextControlSupport | |
| Orders: | 877-462-4772 |

| Author: | TX Text Control Support Department |
| Language: | Visual Basic 6.0 |
| Version: | 1.0 |
| Released: | October 19, 2004 |
| Last modified: | January 11, 2008 |
| Requirements: | TX Text Control ActiveX with Visual Basic 6.0 |
| Download code: | tx_sample_activex_tooltip.zip |

This illustrates how to display a tool tip when the end user moves his/her mouse over a marked text field. This is particularly helpful to display special information or functions of a field for the end user.
For example: A hyperlink will be only followed, if the user presses CTRL and clicks on the link. This functionality needs to be communicated to the end user: A tool tip is a perfect means to transfer this information.
TX Text Control does not have an event that is fired, when the mouse moves over a field. The FieldSetCursor event - normally used to change the cursor style - can, however, be utilized for this purpose.
A second TX Text Control with a yellow background is used for the tool tip itself. On the FieldSetCursor event, the text of the tool tip is specified and a timer is started.
A timer is necessary to hide the tool tip window when it is no longer required. The result is that the tool tip will disappear, if the mouse cursor leaves the field position.
Private Sub TXTextControl1_FieldSetCursor(ByVal FieldId As Integer, _ MousePointer As Integer) Dim TextExtent() As Long MousePointer = 12 TXTextControl1.FieldCurrent = FieldId TXTextControl2.Text = TXTextControl1.FieldTypeData (TXTextControl1.FieldCurrent) + vbCrLf TXTextControl2.SelStart = -1 TXTextControl2.SelText = "CTRL + click to follow link" Timer1.Interval = 100 End Sub Private Sub Timer1_Timer() TXTextControl2.ZOrder 1 Timer1.Interval = 0 End Sub
Now, we just need a global flag to specify whether the CTRL key is pressed or not. This global variable will be used in the FieldClicked event. If the user presses the CTRL key and clicks the field, the default browser will be opened with the current hyperlink.
Private Sub TXTextControl1_FieldClicked(ByVal FieldId As Integer) If CTRL_flag = True Then Result = ShellExecute(Me.hwnd, "Open", TXTextControl1.FieldTypeData _ (TXTextControl1.FieldCurrent),"", App.Path, 1) CTRL_flag = False End If End Sub