Word Wrap toggle function for RichTextBox:   Return to List

' The code below works back and forth with a RichTextBox -- however, only the Wrap ON feature is present with a regular textbox

' Contants and Variables Dealing with Word Wrap of Textbox
Public Const WM_USER = &H400
Public Const EM_SETTARGETDEVICE = (WM_USER + 72)
Public 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

' Placed the following beneath the appropriate option boxes
Private Sub optWrapYes_Click()
    SendMessageLong Text1.hwnd, EM_SETTARGETDEVICE, 0, 0' Turning Word wrap ON
End Sub

Private Sub optWrapNo_Click()
    SendMessageLong Text1.hwnd, EM_SETTARGETDEVICE, 0, 1' Turning Word wrap OFF
End Sub



Note to Webmaster