Inserting Text (Adding) In CEditView :: MFC

Status
Not open for further replies.
Hello.

I have a doc/view program. The view was derived from CEditView. It however, would not display text when I open a text file with text in it.

For example:

Source file:
---
a
b
c
---

When I open that file up, the program copies the text into a CStringArray object. I can change any line by adding or removing text. However, the program will not display the text in view. The only way to get it to display the text is if I type in the text manually.

The view was derived from CEditView. CEditView allows access to the CEditCtrl. Nonetheless, I cannot find a way to *insert* a CString into the CEditCtrl inside of CEditView. Furthermore, I tried drawing the text, but view still would not display anything.

Is it possible to add text or display text in the CEditView without having to manual type it in? CEditCtrl returns a CEdit reference object. There is a function, GetLine(line, string) to get text from a specific line. However, there are no functions to set the text at a specific line.

Thanks,
Kuphryn
 
Okay. Thanks!

I have tried two ways. When the program opens a file, it saves each line of text into a CStringArray object. If there are 10 lines of text, then the CStringArray object will have a size 10. I tried assigning all data from the object into one CString object. I then used SetWindowText() to assign the CString object to CEdit. It works great. The only problem is instead of displaying two separate lines, CEditView combines all ten lines into one line.

I tried call SetWindowText() into a for-loop from i = 0 to i < 10. That works too. However, the display is the same was the one above. It displays one long line of text rather than 10 lines.

I will use your code. It looks very intesting. I will post an update as soon as I get it up and running.

Kuphryn
 
Status
Not open for further replies.