1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| Imports System.Threading
Public Class Form1
'RichTextBox2.text est le texte destination en cours d'écriture
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
RichTextBox1.Text = ""
'lit 8 caractères hexadécimal du tableau unicode
For n = &H2660 To &H2667 ' 54 To &H265F
RichTextBox1.Text += ChrW(n)
Next n
'dessine trois lignes en biais
Dim gdi As Graphics = RichTextBox1.CreateGraphics()
gdi.DrawLine(Pens.Black, New Point(0, 0), New Point(432, 48))
gdi.DrawLine(Pens.Black, New Point(0, 10), New Point(432, 58))
gdi.DrawLine(Pens.Black, New Point(0, 20), New Point(432, 68))
'dessine un rectangle rouge
Dim RedPen As New Pen(Color.Red, 3)
Dim rect As New Rectangle(0, 0, 100, 100)
gdi.DrawRectangle(RedPen, rect)
gdi.Dispose()
End Sub
Private Sub RichTextBox1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles RichTextBox1.MouseDown
'Recherche position de la souris
Dim box = DirectCast(sender, RichTextBox)
'sélectionne le caractère qui reçoit le click
Dim SelectCharacter = box.GetCharFromPosition(e.Location)
'replace le curseur en fin de ligne
SendKeys.Send("{HOME}+{END}")
RichTextBox2.Focus()
'Ajoute le caractères au RichTextBox2
RichTextBox2.Text += SelectCharacter
End Sub
Private Sub RichTextBox2_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs) Handles RichTextBox2.KeyDown
'place le curseur à la fin de la ligne de texte
RichTextBox2.SelectionStart = RichTextBox2.TextLength
End Sub
'Private Sub RichTextBox1_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles RichTextBox1.MouseMove
' 'routine à créer en prévision de la visualisation avec un carrée rouge du caractère survolé
' RichTextBox2.Focus()
'End Sub
End Class |
Partager