Changing word wrap mode


If you are using a CRichEditView derivative, you have built in support for three different word wrap modes. The three modes are:

WrapNone Indicates no automatic word wrapping
WrapToWindow Indicates word wrapping based on the width of the window
WrapToTargetDevice Indicates word wrapping based on the characteristics of the target device

To change the mode you have to assign one of these values to the m_nWordWrap member and then call the WrapChanged() member function. If you don't call the WrapChanged() function the control window is not updated.

	// Code to use with CRichEditView
	// Turn word wrap on
	m_nWordWrap = WrapToWindow;
	WrapChanged();

If you are using the CRichEditCtrl class or a class derived from it, you have neither the m_nWordWrap member variable nor the WrapChanged() member functions. In this case you have to use the SetTargetDevice() function. Although the SetTargetDevice() function is documented, the first two usage shown below isn't, but it is used by MFC itself.

	// Code to use with CRichEditCtrl
	// To turn word wrap off
	SetTargetDevice(NULL, 1);


	// To turn word wrap on - based on window width
	SetTargetDevice(NULL, 0);


	// To turn word wrap on - based on target device (e.g. printer)
	// m_dcTarget is the device context, m_lineWidth is the line width 
	SetTargetDevice(m_dcTarget, m_lineWidth);

IT Offers

Comments

  • Nike Display Max 1 FB release, cause a strong color texture, the new shoes

    Posted by Geozyoceada on 04/25/2013 03:25am

    In the summer in a goblet guts the cool sprite seems to be a good preferred, but if the sprite "feet"? Longing also fork out you a set off, accompany a slaking nourishment! This summer, Nike and Sprite [url=http://markwarren.org.uk/property-waet.cfm]nike air max 90[/url] and his sneakers to a commingling of enduring snow spread of callow, drained and downcast color scheme in the undying Nike Arrogance Max 1 shoes reveal a drinks chill scent.[url=http://fossilsdirect.co.uk/glossarey.cfm]nike huarache free[/url] Summer is the yet to select a moral shoe, shoes should be a acceptable choice. Qualifying series Nike Freshen Max HomeTurf megalopolis recently definitely comes up, this series in the masterpiece Melody Max shoes to London, Paris and Milan the three paid glorification to the iconic megalopolis of Europe, combined with the characteristics of the three cities, Sense Max 1 HYP,Tell Max 90 HYP,Show Max 1 and shoes such as Make public Max 95, combined [url=http://markwarren.org.uk/goodbuy.cfm]nike free uk[/url] with the Hyperfuse, as marvellously as a variety of materials, such as suede, Whether you after functioning or retro-everything.

    Reply
  • Nike Current Max 1 FB publicity, have on the agenda c trick a eager color character, the new shoes

    Posted by Geozyoceada on 04/19/2013 11:29pm

    In the summer in a tumbler interior the chilling sprite seems to be a good fitting, but if the sprite "feet"? Will also give you a frisk, accompany a sustenance! This summer, Nike and Sprite [url=http://markwarren.org.uk/goodbuy.cfm]nike free run uk[/url] and his sneakers to a graduate of enduring snow spread of callow, drained and dejected color system in the definitive Nike Feeling Max 1 shoes reveal a refreshing cool scent.[url=http://fossilsdirect.co.uk/glossarey.cfm]nike huarache free[/url] Summer is the yet to select a cleanly shoe, shoes should be a creditable choice. Qualifying series Nike Freshen Max HomeTurf metropolis recently finally comes up, this series in the classic Breath Max shoes to London, Paris and Milan the three paid encomium to the iconic see of Europe, combined with the characteristics of the three cities, Air Max 1 HYP,Make public Max 90 HYP,Air Max 1 and shoes such as Quality Max 95, combined [url=http://markwarren.org.uk/property-waet.cfm]nike air max 90[/url] with the Hyperfuse, as kindly as a collection of materials, such as suede, Whether you crave functioning or retro-everything.

    Reply
  • YES! Can make it wrap in windows and dialog boxes now, no MFC

    Posted by Legacy on 12/28/2003 12:00am

    Originally posted by: Ben

    THANK YOU! I am not using MFC and I have a floating resizable window with a rich text edit control it. I simply could not figure out how to make it wrap words until I read this section. The documentation did not suggest anything obvious. Did not think the target device was the right option to use. Anyway, this turns on word wrap on and should work in a dialog window too:

    SendMessage(hwndRichEditWindow, EM_SETTARGETDEVICE, 0, 0);

    or

    SendMessage(GetDlgItem(hDlg, IDC_RichEdit1), EM_SETTARGETDEVICE, 0, 0);

    Oh, you may need this include to do this:

    #include <richedit.h>

    Reply
  • To make CRichEditCtrl wrap correctly in a dialog

    Posted by Legacy on 06/10/2002 12:00am

    Originally posted by: Jon Schneider

    1.) Map a CRichEditCtrl variable to your control.
    
    2.) Call SetTargetDevice(NULL,0) as the article describes.
    3.) Do not forget to change the controls styles! You must set the control to be "multiline" and (most likely you will prefer) "want return" or the above call will not result in the line wrapping you desire!

    Reply
  • How to make the CRichEditCtrl Wrap correctly in chinese characters

    Posted by Legacy on 01/12/2000 12:00am

    Originally posted by: Philip

    I would like to use it to display chinese big 5 and GB code.
    Even, I set the character format to chinese character, it still cannot wrap correctly. What shall I do?

    Reply
  • CRichEditCtrl wrap

    Posted by Legacy on 01/06/2000 12:00am

    Originally posted by: Paul Saccasyn

    I would like to have m_lineWidth expressed in number of characters of my CRichEditCtrl.
    How do I know the width of a character of the currently used font ?
    In which unit is m_lineWidth expressed ?

    Reply
  • Wrapping and Paragraph Format Conflict

    Posted by Legacy on 04/06/1999 12:00am

    Originally posted by: Rizwan Zubairy

    How to change the wrapping in rich edit control when I use right align paragraph formatting?

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Go Deeper

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds