From: Leo on
Hi all I am trying to get the current column and line number of a text
control. I have tried sending the EM_GETLINEINDEX message to no avail
using uMessage = RegisterWindowMessage("EM_GETLINEINDEX") . I thought I
should be able to get the column with Me.ActiveControl.SelStart (i am
using Me.ActiveControl because of the need to have two identical
textboxes to provide toggleable wordwrap) but that seems to not work
properly when hitting enter to get to the next line.

--
ClassicVB Users Regroup! comp.lang.basic.visual.misc
Free usenet access at http://www.eternal-september.org


From: Mayayana on
This code goes in a form with a multi-line
textbox named T1 and two labels, Lab1(0)
and Lab1(1).

Private Const EM_LINEFROMCHAR = &HC9&
Private Const EM_LINEINDEX = &HBB&
Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA"
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam
As Long) As Long


Private Sub T1_Click()
Dim LDex As Long, LLine As Long
LLine = SendMessageLong(T1.hWnd, EM_LINEFROMCHAR, T1.SelStart, 0&)
Lab1(0).Caption = CStr(LLine + 1)
LDex = SendMessageLong(T1.hWnd, EM_LINEINDEX, LLine, 0&)
Lab1(1).Caption = CStr((T1.SelStart - LDex) + 1)
End Sub

The demo code above shows it working for a
click in the textbox, but you'll actually need to
respond to left mouseup (click), navigation keys
keyup, and return key keyup.


| Hi all I am trying to get the current column and line number of a text
| control. I have tried sending the EM_GETLINEINDEX message to no avail
| using uMessage = RegisterWindowMessage("EM_GETLINEINDEX") . I thought I
| should be able to get the column with Me.ActiveControl.SelStart (i am
| using Me.ActiveControl because of the need to have two identical
| textboxes to provide toggleable wordwrap) but that seems to not work
| properly when hitting enter to get to the next line.
|


From: Leo on
Mayayana pretended :
> This code goes in a form with a multi-line
> textbox named T1 and two labels, Lab1(0)
> and Lab1(1).
>
> Private Const EM_LINEFROMCHAR = &HC9&
> Private Const EM_LINEINDEX = &HBB&
> Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA"
> (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam
> As Long) As Long
>
>
> Private Sub T1_Click()
> Dim LDex As Long, LLine As Long
> LLine = SendMessageLong(T1.hWnd, EM_LINEFROMCHAR, T1.SelStart, 0&)
> Lab1(0).Caption = CStr(LLine + 1)
> LDex = SendMessageLong(T1.hWnd, EM_LINEINDEX, LLine, 0&)
> Lab1(1).Caption = CStr((T1.SelStart - LDex) + 1)
> End Sub
>
> The demo code above shows it working for a
> click in the textbox, but you'll actually need to
> respond to left mouseup (click), navigation keys
> keyup, and return key keyup.
>
>
>> Hi all I am trying to get the current column and line number of a text
>> control. I have tried sending the EM_GETLINEINDEX message to no avail
>> using uMessage = RegisterWindowMessage("EM_GETLINEINDEX") . I thought I
>> should be able to get the column with Me.ActiveControl.SelStart (i am
>> using Me.ActiveControl because of the need to have two identical
>> textboxes to provide toggleable wordwrap) but that seems to not work
>> properly when hitting enter to get to the next line.

Thankyou very much

--
ClassicVB Users Regroup! comp.lang.basic.visual.misc
Free usenet access at http://www.eternal-september.org