CodeItBetter Programming Another VB Programming Blog

How to toggle Word wrap feature on Rich Text Box

Posted on January 4, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
'Controls - How to toggle Word wrap feature on Rich Text Box
Option Explicit
 
'The code below works back and forth with a RichTextBox -- however, only the Wrap ON feature 
'is present with a regular 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
 
Public Sub WordWrap(rtf As RichTextBox, Optional ByVal bWordWrapOff As Boolean = False)
'if bWordWrapOff = False Then Turning Word wrap ON
'if bWordWrapOff = True  Then Turning Word wrap OFF
    SendMessageLong rtf.hwnd, EM_SETTARGETDEVICE, 0, Abs(bWordWrapOff)
End Sub
Filed under: Controls Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.