Is there any way you can determine the postition of the cursor in a multi-line scrolling RichText box??
I will need this knowledge to make an AutoCompleter for my text editor program!!
Printable View
Is there any way you can determine the postition of the cursor in a multi-line scrolling RichText box??
I will need this knowledge to make an AutoCompleter for my text editor program!!
If you mean the position of the caret then use SelStart property.
I am looking for somehow to determine the exact position of the cursor in fx. pixels (x,y)
I will make a drop-down code-completer a little like the one in the VB editor when you press CTRL+SPACE...
Are you talking about the mouse cursor or the text caret?
I will assume it's the text caret you are talking about.
Then use the GetCaretPos API function:You call it like this:VB Code:
Private Declare Function GetCaretPos _ Lib "user32" (lpPoint As POINTAPI) As Long Public Type POINTAPI x As Long y As Long End TypeBest regardsVB Code:
Dim p As POINTAPI RichTextBox1.SetFocus If GetCaretPos(p) Then MsgBox "The caret is at " & p.x & ", " & p.y End If
The text caret...!
If I for instance in the RichText field type "Ap" and activate some shortcut a drop-down list with suggestons like "Application" appear right below the text caret... The problem is to locate that exact spot...
Now you're making me confused. Didn't you read my last post in this thread?Quote:
Originally posted by Seth DK
The text caret...!
If I for instance in the RichText field type "Ap" and activate some shortcut a drop-down list with suggestons like "Application" appear right below the text caret... The problem is to locate that exact spot...
Use the GetCaretPos API function.
Sorry about that!!
We must have been posting at the same time...lol
Thanks!
Yeah, well you danish people is much like the people form Norway (yes, I'm talking about you peet :)) a bit slow :)Quote:
Originally posted by Seth DK
Sorry about that!!
We must have been posting at the same time...lol
Thanks!
I have experimented with it for some time now, and I can now (thanks to your help) locate the text caret in a text box, but what exactly do I do to the data I get??
It seems it is neither Pixels, nor Twips the numbers are formatted to.
I can make the drop-down list move - also in the correct direction, but it does not follow the cursor - it is moving "slower"
PLEASE ADVICE :-(
Multiplying the x,y coordinates of the point type by 15 appears to give pixels. Anyone know why?
According to the MSDN Library:Client coordinates should be whatever you've set the ScaleMode to.Quote:
The GetCaretPos function copies the caret's position, in client coordinates, to the specified POINT structure.
Screen.TwipsPerPixelX and Screen.TwipsPerPixelY equals 15.Quote:
Originally posted by DaveAMS
Multiplying the x,y coordinates of the point type by 15 appears to give pixels. Anyone know why?
How do i get the posistion in the vb twips ?? What should i multiply/devide with ? please help !
Regards