Hi
Try to create terminal emutalor for VMS.
Need to get cursor to follow the text in a text box and retreive cursor row and column.
thanks
Doug
Printable View
Hi
Try to create terminal emutalor for VMS.
Need to get cursor to follow the text in a text box and retreive cursor row and column.
thanks
Doug
Text box or RichTextBox?
I would prefer the text box solution.
Because I an most familiar with it.
Doug
Doug:
Cursor column is one thing, but cursor row depends entirely on how wide the text box is vs how large the font is, etc, etc.
The property Text1.SelStart can give the character location in the textbox, if that helps...?
If I had a page of text1.text 80 characters wide by 24 rows high.
How would I position the cursor at line/row 15 and character position 10?
thanks
Doug
This function will return the position in pixels, not as row and column, so you might have to convert it somehow.
VB Code:
Private Type POINTAPI X As Long Y As Long End Type Private Declare Function GetCaretPos Lib "user32.dll" (ByRef lpPoint As POINTAPI) As Long Private Sub Text1_Change() Dim pt As POINTAPI GetCaretPos pt Me.Caption = pt.X & ", " & pt.Y End Sub
This might be closer to what you need
VB Code:
Private Const EM_LINEFROMCHAR As Long = &HC9 Private Const EM_LINEINDEX As Long = &HBB Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As Long Private Sub Text1_Change() Dim Xpos As Long Dim Ypos As Long Xpos = Text1.SelStart - SendMessage(Text1.hwnd, EM_LINEINDEX, -1, 0&) + 1 Ypos = SendMessage(Text1.hwnd, EM_LINEFROMCHAR, -1, 0&) + 1 Label1.Caption = Xpos & ", " & Ypos End Sub