Hello,
I there a way to obtain the (x,y) position of a word within a rich text box? For example, within the RTB, there is the phrase:
I can walk a mile.
Can I obtain the cursor position just before the letter 'w' in the word 'walk'?
Thanks.
Printable View
Hello,
I there a way to obtain the (x,y) position of a word within a rich text box? For example, within the RTB, there is the phrase:
I can walk a mile.
Can I obtain the cursor position just before the letter 'w' in the word 'walk'?
Thanks.
You can easily get the mouse position inside a textbox by simply using:
VB Code:
Private Sub RichTextBox1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
The x and y values returned is the position of the pointer inside the textbox, not the form. As for character positions you can get the y value for a line easily enough, but because characters are different widths, you can't get the x value, i don't think, unless you were willing to move along the line one character at a time and add up the width, though that would mean finding the width of every character and using a select case.
Kazar,
Thanks for the reply.
The strings within the RTB are bing fed by the application, so Mousemove doesn't come into play. I did consider the idea of building a table of character widths, but screen resolutions will affect that on different users' terminals.
you can get the screen res i think and use that as a multiplier