finally i found another way
Code:
Option Explicit
Private Const WM_USER = &H400
Private Const EM_SETTARGETDEVICE = (WM_USER + 72)
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 Sub Form_Load()
SendMessage RichTextBox1.hwnd, EM_SETTARGETDEVICE, 0, ByVal -1&
End Sub
i have tested and works fine(don't forget show the scrollbars
).
so what is the diference between righmargin and these? seems these code desactivate the wordwrap property and the horizontal scrollbar is showed only after write some text.
but i have update the code:
module:
Code:
Private Const WM_USER = &H400
Private Const EM_SETTARGETDEVICE = (WM_USER + 72)
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
Public Sub WordWrap(ControlHandle As Long, ActivateWordWrap As Boolean)
If ActivateWordWrap = False Then
SendMessage ControlHandle, EM_SETTARGETDEVICE, 0, ByVal -1&
Else
SendMessage ControlHandle, EM_SETTARGETDEVICE, 0, ByVal 0&
End If
End Sub
how use it:
Code:
Private Sub Command1_Click()
WordWrap RichTextBox1.hwnd, False
End Sub
these code works fine with RichTextBox control but these code, not tested with another controls, can be used with another controls
thanks for all