|
-
Oct 10th, 2000, 03:12 PM
#1
Thread Starter
Frenzied Member
OK I am kind of new at VC++ and really new to MFC programs.
I have a MFC FormView program that has just an Edit Box on a form. What I want to do is save the text from the Edit Box to a file also write the text from a text file to the edit box.
In my View Object I have DoData Exchange that saves the text to a VAR called editTextOut.
Code:
void CTestMFCFrmViewDoc::Serialize(CArchive& ar)
{
CString F = "";
//#1 CTestFrmViewView* pView = (CTestFrmViewView*)m_viewList.GetHead();
//#2 ASSERT_KINDOF(CTestFrmViewView, pView);
if (ar.IsStoring())
{
pView->UpdateData();
F = pView->editTextOut;
ar << F;
}
else
{
ar >> F;
pView->RedrawWindow(NULL,NULL, RDW_ERASENOW);
}
}
Question 1: Is using //#1 & //#2 the correct way to point pView to the CTestFrmViewView object? I got this from an example somewhere else, but it just seems like the wrong way to do it.
Question 2: After I read in the text from a text file how do I send the edit box?
Thanks
MSVS 6, .NET & .NET 2003 Pro
I HATE MSDN with .NET & .NET 2003!!!
Check out my sites:
http://www.filthyhands.com
http://www.techno-coding.com

-
Oct 10th, 2000, 03:23 PM
#2
Frenzied Member
If you like you can use this code to open a file.
Code:
#include <string>
#include <fstream>
using namespace std;
string got,all;
ifstream in(filename);
while(getline(in,got))
{
all += got + "\r\n";
}
edit = all.c_str();
UpdateData(FALSE);
Answer 2:
Code:
edit = varcontainingtext;
UpdateData(FALSE);
-
Oct 10th, 2000, 04:49 PM
#3
Thread Starter
Frenzied Member
Ahh Thanks Vlatko but I already can read from a file thats what ar >> F; does.
I wanted to be sure that the code I am using is the correct way of doing it.
Incase someone else reads this here is how to put the text to the edit box using my code.
Code:
pView->editTextOut = F;
pView->UpdateData(false);
Thanks for the help Vlatko
MSVS 6, .NET & .NET 2003 Pro
I HATE MSDN with .NET & .NET 2003!!!
Check out my sites:
http://www.filthyhands.com
http://www.techno-coding.com

Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|