Results 1 to 3 of 3

Thread: Some Questions

  1. #1

    Thread Starter
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024

    Question

    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


  2. #2
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    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);
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  3. #3

    Thread Starter
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    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
  •  



Click Here to Expand Forum to Full Width