SDI - Displaying data in a View window and modifying it using a Custom Dialog box

Posted on 2005-05-01
Last Modified: 2013-11-20
I have created a dialog based MFC program, which will read in a student record (name, num of grades,type of test, letter grade and number grade) and then edit each of the data members (by calling a custom dialog through a button). The way I handled the "reading from file" and writing to file" from the Student class is by defining:
istream & operator >> (istream& is,CStudent& s) to input data and
stream & operator<<(ostream& os, const CStudent& s) to output data.
I would then open a file from the Dialog application this way:
ifstream ifl;"student1.txt");
Then I would call ifl >> s from the Project1Dlg.cpp to load data into the object "s" (which is of type CStudent), then would retrieve each of the data members and format them to be displayed onto the text boxes and list boxes. In the same way, I would call ifl<<s  from Project1Dlg.cpp to restore the file with the modifed data members.

The student record in the file student1.txt looks like this(the variables are listed along with it):
Joe Green      // mFirstname    mLastname
14                 // mNumofGrade
Test1 A 100   // mTestaname   mLetGrade   mNumGrade
Test2 A 99
Test3 A 98
Test4 A 97

Now, I would like to use the student record program but with an SDI application (doc view architecture).
I would like to make files of type .rec to be only displayed when selecting "open" (which I know how to do by changing the properties in the String Table).
The text of the file has to be displayed in the View window (raw format), and I would like to call a custom dialog from the menu choice to edit all the data in the single record and update them in memory.
I want to eliminate the Save/Exit buttons that I used in the dialog box, and want to save using the "Save" and "Save as" menu choices already available in the SDI app.
I've played around well with dialog boxes but am a little confused about how to handle SDI (doc/view and synchronization) ?? Should I used "CEditView" as my base class here? If so, how would I read the data from the CEditView and then store it into variables, which would need to be updated when I modify all the data in the record with the Custom dialog box?? How could I write back to the CEditView from the Control variables in the Custom dialog box??

Any sample code would be really useful. thanks for your help!

Question by:Testsubbu
    LVL 55

    Accepted Solution

    LVL 3

    Expert Comment

    You Store all data in Document then access this data from dialog and modify it.

    In View just display this data

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
    Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now