Hi guys...
I need some help here translating an API call from VB6 to .net...
The use of this is to be able to know the cursor position on a RichTextBox.
The VB6 code looks like this:
I really cant port this stuff to vb.net...
Thanks!
Alex
I need some help here translating an API call from VB6 to .net...
The use of this is to be able to know the cursor position on a RichTextBox.
The VB6 code looks like this:
Code:
Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const EM_LINEFROMCHAR = &HC9
Private Const EM_LINEINDEX = &HBB
Private Const EM_GETSEL = &HB0
Private Declare Function SendMessageReferenceParams Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByRef wParam As Long, ByRef lParam As Long) As Long
Private Sub CheckPosition()
Dim start_pos As Long
Dim end_pos As Long
Dim row As Long
Dim col As Long
SendMessageReferenceParams _
Text1.hwnd, EM_GETSEL, start_pos, end_pos
row = SendMessage(Text1.hwnd, EM_LINEFROMCHAR, start_pos, 0) + 1
col = start_pos - SendMessage(Text1.hwnd, EM_LINEINDEX, -1, 0) + 1
lblPosition.Caption = "(" & Format$(row) & ", " & Format$(col) & ")"
End Sub
Private Sub Form_Resize()
Dim hgt As Single
hgt = ScaleHeight - lblPosition.Height
If hgt < 120 Then hgt = 120
Text1.Move 0, 0, ScaleWidth, hgt
lblPosition.Move 0, hgt, ScaleWidth
End Sub
I really cant port this stuff to vb.net...
Thanks!
Alex