Solved

Word wrap in CEdit control

Posted on 2001-06-05
8
5,855 Views
Last Modified: 2013-11-20
Hi,

I'm having a MFC Dialog application that has an edit control (CEdit). This control can accept a maximum of 250 characters. This control is multiline and can accept a maximum of 40 characters per line.

As the user keys in text, I need a mechanism to wrap the text after every 40 characters to a new line. CEdit don't seems to support this directly.

Can anyone help me to implement my requirement ?.
Will CRichEditCtrl be of any help ?

Thanks,
sindbad



0
Comment
Question by:sindbad
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 1

Expert Comment

by:Black_End
ID: 6157295
Read about EM_FMTLINES and CEdit::FmtLines
0
 
LVL 86

Accepted Solution

by:
jkr earned 100 total points
ID: 6157376
All you have to do is removing 'ES_AUTOHSCROLL' from the edit control, and it'll handle the word wrap
by itself. Try that in the resource editor.
0
 
LVL 1

Expert Comment

by:tvanceplus
ID: 6157593
jkr is right. I use CEdit controls with edit resources with that facility all the time to get the user to enter text.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:jtwine100697
ID: 6157662
  EM_FMTLINES is only used to specify the inclusion of "soft breaks" in the actual text buffer of the control to match the breaks visible on-screen.

   The ES_AUTOHSCROLL style only causes lines to break when they hit the visible limits of the edit control.  So using a smaller font will change the "break" behavior.

   If you only need the text broken up into "lines of 40 characters or less" for some kind of processing AFTER the user enters the data, then why not manually break up the text after the user is finished entering it?  Or is there a requirement that it has to be broken while being entered in your interface?

   You *MAY* be able to use EM_SETWORDBREAKPROC to specify your own word-break function, and "backing-up" in the text stream (on a line-by-line basis) looking for the end of a word before or at character position 40, when you get a callback for "WB_LEFT".  No promises, though...

-=- James.
0
 
LVL 4

Expert Comment

by:jtwine100697
ID: 6157664
> The ES_AUTOHSCROLL style

   Oops.  That should read "Removing the ES_AUTOHSCROLL style".

-=- James.
0
 
LVL 1

Expert Comment

by:tvanceplus
ID: 6157736
i think i misread your question. sorry.
0
 

Author Comment

by:sindbad
ID: 6157774

Yes JKR,

It works. Oh, such a simple solution.
Thanks,

Sindbad
0
 
LVL 4

Expert Comment

by:jtwine100697
ID: 6158231
Entropy abounds... :(

-=- James.
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
In this post we will learn different types of Android Layout and some basics of an Android App.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question