Solved

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

Posted on 2001-07-27
7
174 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Expert Comment

by:ocbb
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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 video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

771 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

8 Experts available now in Live!

Get 1:1 Help Now