Solved

Word wrap in CEdit control

Posted on 2001-06-05
8
5,821 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
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
Industry Leaders: 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

Technology Partners: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
repeateFront java challenge 31 95
Perl Awk Need Help 3 136
MaxSpan challenge 9 122
Authenticate using sesu from script 7 106
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.

685 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