|
-
Dec 20th, 2001, 02:33 PM
#1
Cursor position!!!
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!!
-
Dec 20th, 2001, 02:35 PM
#2
If you mean the position of the caret then use SelStart property.
-
Dec 20th, 2001, 02:49 PM
#3
Not what I mean
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...
-
Dec 20th, 2001, 02:52 PM
#4
Are you talking about the mouse cursor or the text caret?
-
Dec 20th, 2001, 02:59 PM
#5
I will assume it's the text caret you are talking about.
Then use the GetCaretPos API function:
VB Code:
Private Declare Function GetCaretPos _
Lib "user32" (lpPoint As POINTAPI) As Long
Public Type POINTAPI
x As Long
y As Long
End Type
You call it like this:
VB Code:
Dim p As POINTAPI
RichTextBox1.SetFocus
If GetCaretPos(p) Then
MsgBox "The caret is at " & p.x & ", " & p.y
End If
Best regards
-
Dec 20th, 2001, 03:02 PM
#6
The text caret...!
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...
-
Dec 20th, 2001, 03:08 PM
#7
Re: The text caret...!
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...
Now you're making me confused. Didn't you read my last post in this thread?
Use the GetCaretPos API function.
-
Dec 20th, 2001, 04:03 PM
#8
Oops
Sorry about that!!
We must have been posting at the same time...lol
Thanks!
-
Dec 20th, 2001, 09:02 PM
#9
Re: Oops
Originally posted by Seth DK
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
-
Dec 21st, 2001, 08:47 AM
#10
Still having problems...
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 :-(
-
Dec 21st, 2001, 09:29 AM
#11
Lively Member
Multiplying the x,y coordinates of the point type by 15 appears to give pixels. Anyone know why?
-
Dec 21st, 2001, 05:18 PM
#12
According to the MSDN Library:
The GetCaretPos function copies the caret's position, in client coordinates, to the specified POINT structure.
Client coordinates should be whatever you've set the ScaleMode to.
Originally posted by DaveAMS
Multiplying the x,y coordinates of the point type by 15 appears to give pixels. Anyone know why?
Screen.TwipsPerPixelX and Screen.TwipsPerPixelY equals 15.
-
Sep 26th, 2002, 02:18 PM
#13
Frenzied Member
Ehh ? Twios, howto ?
How do i get the posistion in the vb twips ?? What should i multiply/devide with ? please help !
Regards
"Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
- Zack de la Rocha
Hear me roar.
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
|