Sign in to follow this  
Phex

MFC: CEdit trouble

Recommended Posts

Phex    140
Hello I am working on a window application including an uneditable CEdit Control with automatic line break. My aim is to display a text in it that was read out of a text file via FILE* stream. But I am experiencing two major problems: 1) It does not seem possible to attach text to a CEdit. This means, when I read in each line of the file seperately, I have to store all the text in one (really BIG) buffer and copy this buffer to the CEdit (with SetWindowText()). Its possible that this buffer may overflow when the text file is too huge. Is there a way to attach text to a CEdit or another solution to avoid this problem? 2) The line break does not work when I try to display the text read out of my file. All newline characters ('\n') are shown as black boxes, but I can manually add a new line when I make the CEdit editable and press return. How can I solve this problem? Thank you for your help! rgds, Phex

Share this post


Link to post
Share on other sites
enmaniac    197
As far as I know it is possible to attach text to CEdit control. But instead of using SetWindowText function (I am guessing you are using this one) use this set of functions GetLine, SetSel, GetSel, and ReplaceSel.

Did you specifiy ES_MULTILINE style for your edit ??

EDIT: new line char for edit control is '\n\r' rather than '\n'...

Share this post


Link to post
Share on other sites
Phex    140
Quote:
Did you specifiy ES_MULTILINE style for your edit ??

Yeah, I can also create new lines myself in the box when pressing return.

Quote:
EDIT: new line char for edit control is '\n\r' rather than '\n'...

I tried it out, but it didnt work...
EDIT: Stupid me, it worked! Thanks!

I still do not get the point with attaching text. I already searched at several places, but I dont get reasonable information.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this