Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Word wrap in CEdit control

Posted on 2001-06-05
8
Medium Priority
?
5,927 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 300 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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…
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.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Suggested Courses

618 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