Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2001-07-27
7
Medium Priority
?
232 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 200 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

886 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