Solved

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

Posted on 2001-07-27
7
200 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
conditional code and condition difference 9 82
Hibernate methods 2 71
countEvens challenge 2 100
no14 challenge 14 67
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: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
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.

777 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