Is there any easy way to set the SelStart at the beginning of the current line (or at any line for that matter)
I know you can get the current line but....
Thanks
Printable View
Is there any easy way to set the SelStart at the beginning of the current line (or at any line for that matter)
I know you can get the current line but....
Thanks
Off the top of my head...
there's probably a hell of a lot easier way, but its late...Code:
x = rtf.GetLineFromChar(rtf.SelStart)
Do Until rtf.GetLineFromChar(rtf.SelStart) = x-1
rtf.SelStart = rtf.SelStart -1
Loop
rtf.SelStart = rtf.SelStart + 1
or perhaps...can you SendKeys the HOME key? I don't know.
Here you go:
When you pass -1 in the wParam argument you'll get the first character position of the current line.Code: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_LINEINDEX = &HBB
Public Sub JumpToStartOfLine(rtb As RichTextBox)
rtb.SelStart = SendMessage(rtb.hWnd, EM_LINEINDEX, -1, 0)
End Sub
You could pass any line number to this argument.
Best regards
Joacim,
A question related to your SendMessage solution...
I've noticed that a lot of people use SendMessage for a lot of different things... what's the best way to find out what Messages to send to what types of forms/windows to get particular results?
Thanks...
Thanks Joacim ..thats PERFECT
much faster now...(instead of starting at the beginning and rechcking verything...just does current line!)
Ohhh.... There are thousands of different messages you can send.Quote:
Originally posted by Achichincle
Joacim,
A question related to your SendMessage solution...
I've noticed that a lot of people use SendMessage for a lot of different things... what's the best way to find out what Messages to send to what types of forms/windows to get particular results?
One source is of course the MSDN Library.
You can for example search for messages starting with WM_????? or for TextBox and RTF boxes they start with EM_?????.
For Command buttons, Checkboxes and Option buttons the messages starts with BM_???? or BN_?????
Best regards
Joacim,
Ok. Thanks. I see them in the MSDN now...