In this newsletter, we are going to show you how to create a feature that is very popular in some well known word processing applications - especially in applications where very small text is displayed.
TX Text Control has a build-in zoom property, so that the text can be zoomed up to 400 percent. But in some cases, users should not zoom in and out endlessly just to read the small characters
To solve this problem, we are going to use a second TX Text Control that displays parts of TX Text Control zoomed to a higher level.
Private Sub TXTextControl1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim data() As Byte
If (DisplayMagnifier = True) Then
TXTextControl1.MousePointer = 12
TXTextControl2.Visible = True
TXTextControl2.LockWindowUpdate = True
CurrentInputPosition = TXTextControl1.InputPosFromPoint(X, Y)
If (CurrentInputPosition <> -1) Then
TXTextControl1.SelStart = CurrentInputPosition - 5
TXTextControl1.SelLength = 15
data = TXTextControl1.SaveToMemory(3, True)
TXTextControl2.LoadFromMemory data, 3, False
TXTextControl2.ZOrder
TXTextControl2.Move X + 100, Y + 1000
Else
TXTextControl2.Visible = False
TXTextControl1.ZOrder
TXTextControl1.Refresh
End If
Else
TXTextControl2.Visible = False
TXTextControl1.MousePointer = 0
End If
End Sub
We use the InputPosFromPoint method to get the character index position of the current mouse location. The parameters of the MouseMove event can be used with the InputPosFromPoint method. Using this position, we can select a piece of text which should be displayed in the magnifier TX Text Control. Thus, the text around the current mouse position will be copied into the second TX Text Control, using the SaveToMemory and LoadFromMemory method. We also use the X and Y coordinates from the MouseMove event parameters to move the second TX Text Control which contains the zoomed text.
In our sample application, we use a right click context menu to enable and disable the magnifier TX Text Control.
Best regards
The Newsletter Team