Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CEdit Multiline, Load Problem

Status
Not open for further replies.

ronnyjljr

IS-IT--Management
Nov 23, 2003
249
US
Hello again.

I am trying to save text from a multiline CEdit control.
I used GetWindowText() and it retrieves the data as one giant line, which is ok. Now when I load the text back in, the only text that is loading is the text before the first newline. So I tried converting it to a Cstring and used the trim function to trim the \r\n and \n characters before writing to a file. But I still can not get it to load past the first newline character. Any help?

-Ron

/**************
Me: When will the project be finished?
Them: What project?
Me: The one you have been working on for the last 3 years!
Them: Ohh, we can't finish it?
Me: Why?
Them: We don't know how to program...
 
BTW I am using fgets(fp,line,1000);
To get the lines.. Maybe my problem?

-Ron

/**************
Me: When will the project be finished?
Them: What project?
Me: The one you have been working on for the last 3 years!
Them: Ohh, we can't finish it?
Me: Why?
Them: We don't know how to program...
 
Since you're using MFC anyway you could use CFile to read the entire string. It doesn't get much easier then this:

Code:
  CString txt;
  {
    CFile f("theFilename",CFile::modeRead);
    DWORD len = f.GetLength();
    f.Read(txt.GetBuffer(len),len);
    txt.ReleaseBuffer();
  } // CFile closed automatically when leaving scope

  // txt now holds the entire file.

If this doesn't work then your problem is elsewhere. You sure the edit control is has its multiline style set?


/Per
[sub]
"It was a work of art, flawless, sublime. A triumph equaled only by its monumental failure."[/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top