Current cursor position in a Rich Text Box
hi all,
I have a problem to solve. I need the current cursor position of the Rich Text Box. If I use the RTb.SelStart, I am getting position of the cursor in Text content. But I want the position in RTF Content. Is there any way to get this ? Kindly help me !!
Regards,
Reshmi
Re: Current cursor position in a Rich Text Box
MsgBox RichText1.SelStart
SelStart property returns cursor position
Re: Current cursor position in a Rich Text Box
Re: Current cursor position in a Rich Text Box
Hi Reshmi ! Welcome to the forums ! :wave:
Unfortunetly there is no straight way to get current cursor position from TextRTF. here is my idea. I hope it will give you some better ideas. :)
Re: Current cursor position in a Rich Text Box
VB Code:
'in form
Private Sub Timer1_Timer()
Dim PT As POINTAPI
GetCaretPos PT
Me.Caption = "X: " & PT.X & " Y: " & PT.Y
End Sub
'in module
Public Declare Function GetCaretPos Lib "user32" (lpPoint As POINTAPI) As Long
Type POINTAPI
X As Long
Y As Long
End Type
Public POINTAPI As POINTAPI
Re: Current cursor position in a Rich Text Box
...but that doesn't give you the insertion point in TextRTF. (Like SelStart is for .Text)