|
-
May 11th, 2006, 03:26 PM
#1
Thread Starter
Junior Member
[RESOLVED] Cursor position within rich text box
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.
-
May 11th, 2006, 03:45 PM
#2
Hyperactive Member
Re: Cursor position within rich text box
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
The Law Of Programming:
As the Number of Lines of code increases, the number of bugs generated by fixing a bug increases exponentially.
__________________________________
www.startingqbasic.co.uk
-
May 11th, 2006, 03:55 PM
#3
Thread Starter
Junior Member
Re: Cursor position within rich text box
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.
-
May 11th, 2006, 04:00 PM
#4
Hyperactive Member
Re: Cursor position within rich text box
you can get the screen res i think and use that as a multiplier
KAZAR
The Law Of Programming:
As the Number of Lines of code increases, the number of bugs generated by fixing a bug increases exponentially.
__________________________________
www.startingqbasic.co.uk
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|