PDA

Click to See Complete Forum and Search --> : RTF again


QWERTY
Nov 5th, 1999, 10:49 AM
How can I do it so when there is too many characters in one line it will automatically send cursor to another line? In RichTextBox

------------------
Visual Basic Programmer (at least I want to be one)
-----------------
PolComSoft
You will hear a lot about it.




[This message has been edited by QWERTY (edited 11-05-1999).]

Yonatan
Nov 5th, 1999, 06:22 PM
Try using the EM_LINELENGTH message, like this:

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_LINELENGTH = &HC1


Private Const MaxLineLength = 20 ' Change to... Whatever...


Private Sub RichTextBox1_Change()
If SendMessage(RichTextBox1.hWnd, EM_LINELENGTH, RichTextBox1.SelStart, ByVal 0&) >= MaxLineLength Then RichTextBox1.SelText = vbNewLine
End Sub


------------------
Yonatan
Teenage Programmer
E-Mail: RZvika@netvision.net.il
ICQ: 19552879 (http://www.icq.com/19552879)

Dingo
Nov 5th, 1999, 07:04 PM
Set the RichTextBox's RightMargin property to the max line length that you want this will start the text wrap once the line is the max length. If you wish to stop the text wrap altogether set it to around 99999.

[This message has been edited by Dingo (edited 11-06-1999).]