Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

Toggle wordwrap in RichEdit control

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Toggle wordwrap in RichEdit control

    In a discussion in the third party forum, I was motivated to write some code to toggle the wordwrap mode of a richedit control. I thought it would be as simple as changing some window styles, but that doesn't work. I searched the web and found an undocumented use of a strange richedit message which solved the problem.

    Here is the DDT code to toggle wordwrap mode in the richedit:

    Code:
    SUB DDT_ToggleWordWrap(BYVAL hDlg&, BYVAL RichID&, BYVAL WrapFlag&)
        LOCAL hCtrl&, Op&, WS&, V&
        CONTROL HANDLE hDlg&, RichID& TO hCtrl&
        WS&=GetWindowLong(hCtrl&, %GWL_STYLE)
        IF WrapFlag& THEN
            WS&=WS& OR %WS_HSCROLL OR %ES_AUTOHSCROLL
            V&=1
        ELSE
            WS&=WS& AND NOT(%WS_HSCROLL OR %ES_AUTOHSCROLL)
            V&=0
        END IF
        SetWindowLong hCtrl&, %GWL_STYLE, WS&
        SetWindowPos hCtrl&, 0,0,0,0,0,%SWP_DRAWFRAME OR %SWP_FRAMECHANGED OR %SWP_NOMOVE OR %SWP_NOOWNERZORDER OR %SWP_NOSIZE OR %SWP_NOZORDER
        SendMessage hCtrl&, %EM_SETTARGETDEVICE, 0,V&
    END SUB

    This is the only reference I found to this on the MSDN web site (and it is a comment left by a user).
    http://msdn.microsoft.com/en-us/libr...82(VS.85).aspx
    There are a number of web pages on the internet that do make reference to this feature.
    Last edited by Chris Boss; 12 Sep 2008, 12:09 AM.
    Chris Boss
    Computer Workshop
    Developer of "EZGUI"
    http://cwsof.com
    http://twitter.com/EZGUIProGuy
Working...
X