Nidonocu
New member
My first post, hope this is in the right place.
I'm trying to get some code which displays the nearest character to a point on my rich text box control for then later finding a perticular character and I've been expriementing with different code to try and do this. This code below is the closest I have so far but for some reason (0, 0) is in the wrong place. I've attached an image, the green dot shows where I want it to be and the red dot shows about where the mouse was when the screencap was taken, the status bar label (CharIdx) showing 0, 0 as the location.
Sorry about the variable names.
I'm trying to get some code which displays the nearest character to a point on my rich text box control for then later finding a perticular character and I've been expriementing with different code to try and do this. This code below is the closest I have so far but for some reason (0, 0) is in the wrong place. I've attached an image, the green dot shows where I want it to be and the red dot shows about where the mouse was when the screencap was taken, the status bar label (CharIdx) showing 0, 0 as the location.
VB.NET:
Private Sub FormMain_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
Dim pikachu As New Point(System.Windows.Forms.Cursor.Position)
Dim raichu As New Point(RichTextBoxOutput.Location)
Dim pichu As New Point(Me.Location)
Dim bulbasaur As Integer = RichTextBoxOutput.GetCharIndexFromPosition(pikachu - (raichu + pichu))
Dim charmander As String = RichTextBoxOutput.GetCharFromPosition(pikachu - (raichu + pichu))
CharIdx.Text = Convert.ToString(bulbasaur) & " - " & charmander & " - " & Convert.ToString(pikachu - (raichu + pichu))
End Sub