Solved

how to add functionality to File New, open, save,saveas etc in SDI

Posted on 2001-07-27
7
189 Views
Last Modified: 2013-11-20
i have created an SDI application.i have File New, Open, Save and save as options under File menu Option.I am not getting File Dailog when I press File/open nor when i press File /Save.Can anyone tell me how to create a new File, Open it, save it etc
0
Comment
Question by:uma99
7 Comments
 
LVL 16

Expert Comment

by:imladris
ID: 6328018
You need to override the OnOpenDocument method of your document class and call the file dialog from there.

Putting up the standard dialog can be done with something like:

     CFileDialog dlg1(TRUE);
     if(dlg1.DoModal()!=IDOK)return;

The filename selected can be found with dlg1.getPathName().

0
 

Accepted Solution

by:
ocbb earned 50 total points
ID: 6339287
uma99,
You must also override the CDocument::Serialize member function. This is where you'll put your "open" and "save" code.


void CMyDoc::Serialize(CArchive& ar)
{

//CDocument::Serialize gets called by the framework when you open or close a document. It provides your //application with the basic functionality of handling persisted data. In effect, the CArchive argument is a file //that you read and write from. The framework opens and closes the file for you.

//The file you'll be reading from or writing to is ar.GetFile(), of type CFile. You can read/write to/from the //CArchive using ar.GetFile()->Read() and ar.GetFile()->Write().
//You can also use a CArchive like a CStdioFile by calling ar.ReadString() and ar.WriteString().
//see msdn for more details.

     if (ar.IsStoring())
     {
          //add storing (saving) code here.
         
     }
     else
     {
          //add opening code here
     }
}


hope this helps.
Errol
0
 

Author Comment

by:uma99
ID: 6341158
Hi Errol,
Thanks for ur reply, Could u please explain me in detail about serilaization.
And what type of File is that i am going to open or save.How to know that or decide that.
I my applcation as i said before i have to create a profile for the user, which includes his options for different settings like fonts, icons etc. and save the profile.'
Thus each profile has to be openedd either as new or exixting then make selection and save changes.
now how should serialization will capture those options selectedby user.

Thank you
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Expert Comment

by:ocbb
ID: 6341870
uma99,

Serialization is just a fancy name for reading or writing data (to hard disk in this case). You mention you are reading and writing user profiles. Are you sure you want to use the document to do this? The reason I ask is that documents are usually user-independant data. Profiles are the other hand are user specific and are typically stored in .ini files.

Errol

0
 

Author Comment

by:uma99
ID: 6342108
what exactly i have to do is to able to create a structure similar to the folders and files structure in Windows.
My application has Projects which contain profiles.Each profile has user info and user options.
Hence when user creates a project he has to create porfiles in it . he can save these profiles update and open for later use.
Profile---|
          |
          |_Profile 1
          |
          |- Profile2
something like this
Thank u for ur response
bye
uma
0
 
LVL 1

Expert Comment

by:Tim_Musschoot
ID: 6363969
U could also use the CStdioFile class to write text files.  First U override the ON_FILE_NEW ON_FILE_OPEN ON_FILE_SAVE messages in the view class of your document. Call the CFileDialog manually and use the fileclass mentioned above.  More details on msdn.microsoft.com/library

Tim Musschoot
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 9490572
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Answered by : ocbb

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Roshan Davis
EE Cleanup Volunteer
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Separate files macro - Errors on larger data set 18 65
Looking for a specific application/software 2 104
isEverywhere  challenge 19 72
matchUp  challenge 9 93
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

911 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

26 Experts available now in Live!

Get 1:1 Help Now