tonofsteel
Active member
- Joined
- Jul 10, 2003
- Messages
- 35
I have been trying to successfully get the following code to work for about 8 hours now. Its starting to get a little frustrating to say the least, especially since it is probably something small I am missing. Anyways I am using Visual basic .net Standard and the following code is all in a module. I have excluded all the non relevant code, any help would be appreciated.
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As IntPtr, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
Public Const EM_GETLINECOUNT As Long = &HBA
Public Const EM_GETSEL As Long = &HB0
Public Const EM_LINEFROMCHAR As Long = &HC9
Public Const EM_LINEINDEX As Long = &HBB
Public Const EM_LINELENGTH As Long = &HC1
Public Const EM_LINESCROLL As Long = &HB6
Public Const EM_SCROLLCARET As Long = &HB7
Public Const EM_SETSEL As Long = &HB1
Public Const WM_SETREDRAW As Long = &HB
In the following the StartofLine sendmessage always returns a 0 no matter what I try. The Length of line always returns the length of the first line. And the net result is the first line being highlighted, ALWAYS. Even if i manually edit LineNumber to say 3 or something.
Dim StartofLine As Long
Dim LineNumber As Long
Dim LengthofLine As Long
Dim CharacterIndex As Long
CharacterIndex = FindMyText(ctl, HighString, 0, 0)
LineNumber = ctl.GetLineFromCharIndex(CharacterIndex)
StartofLine = SendMessage(ctl.Handle, EM_LINEINDEX, LineNumber, 0)
LengthofLine = SendMessage(ctl.Handle, EM_LINELENGTH, LineNumber, 0)
ctl.Select(StartofLine, LengthofLine)
The following Code works with sendMessage, so why not EM_LINEINDEX??????????
Public Function CountLines(ByVal ctl As RichTextBox) As Integer
Return (SendMessage(ctl.Handle, EM_GETLINECOUNT, 0, 0))
End Function
Any help would be appreciated
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As IntPtr, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
Public Const EM_GETLINECOUNT As Long = &HBA
Public Const EM_GETSEL As Long = &HB0
Public Const EM_LINEFROMCHAR As Long = &HC9
Public Const EM_LINEINDEX As Long = &HBB
Public Const EM_LINELENGTH As Long = &HC1
Public Const EM_LINESCROLL As Long = &HB6
Public Const EM_SCROLLCARET As Long = &HB7
Public Const EM_SETSEL As Long = &HB1
Public Const WM_SETREDRAW As Long = &HB
In the following the StartofLine sendmessage always returns a 0 no matter what I try. The Length of line always returns the length of the first line. And the net result is the first line being highlighted, ALWAYS. Even if i manually edit LineNumber to say 3 or something.
Dim StartofLine As Long
Dim LineNumber As Long
Dim LengthofLine As Long
Dim CharacterIndex As Long
CharacterIndex = FindMyText(ctl, HighString, 0, 0)
LineNumber = ctl.GetLineFromCharIndex(CharacterIndex)
StartofLine = SendMessage(ctl.Handle, EM_LINEINDEX, LineNumber, 0)
LengthofLine = SendMessage(ctl.Handle, EM_LINELENGTH, LineNumber, 0)
ctl.Select(StartofLine, LengthofLine)
The following Code works with sendMessage, so why not EM_LINEINDEX??????????
Public Function CountLines(ByVal ctl As RichTextBox) As Integer
Return (SendMessage(ctl.Handle, EM_GETLINECOUNT, 0, 0))
End Function
Any help would be appreciated