Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2001-07-27
7
210 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
How to determine file rename from EventLog ? 2 54
zeroMAx challenge 20 111
Dell Alienware Graphics Amplifier Driver for non-Alienware systems 18 340
Thin secure Windows 10 5 102
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…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

839 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