Solved

C++ how to serialize with options?

Posted on 1998-07-22
4
212 Views
Last Modified: 2010-04-01
null
0
Comment
Question by:kittles
  • 2
  • 2
4 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 50 total points
ID: 1168412
The Open and Save As dialog boxes are Windows common dialog boxes. They are encapsulated by CFileDialog class in MFC.

CFileDialog FileDlg(TRUE,  // TRUE for Open or FALSE Save As
                    NULL,
                    NULL,
                    OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
                    NULL,
                    this);  // the parent window is your dialog box

if (FileDlg.DoModal() == IDOK)
{
    CString strPathName = FileDlg.GetPathName();
    // ...
    // open or save your file
}

0
 

Author Comment

by:kittles
ID: 1168413
Thanks so much for your quick response! Your mention of CFileDialog helped me so much to go in the right direction- now I can access the MFC online library for more help. However, one final question? Now I understand what it takes to bring up the windows pre-created dialog boxes- but where in the code do I insert that command? and will I have to re-write my preexisting OnFileSave and OnFileLoad serialize/archive commands? Or will this new script simply enhance the old by adding the new dialog box and still using the archive feature to save and recover the variable information?
If you can please just tell me where to place that CFileDialog script- it will help lots. I found and understand a majority of the information regarding CFileDialog now... MFC library just didn't assume this was C++ for dummies like me :P and left out the obvious part about where to declare it.
Sure appreciate your help!!
0
 
LVL 23

Expert Comment

by:chensu
ID: 1168414
Since your application is dialog based, you may add a button in your dialog box. When the button is pressed, a member function is called. The ClassWizard can generate this part for you. In that member function, you call CFileDialog to get the full path name of the file. Then you need to use CFile class to open or create the file and pass the pointer of the CFile object to CArchive constructor. Thus you can use CArchive::operator >> and CArchive::operator <<.
0
 

Author Comment

by:kittles
ID: 1168415
Thanks so much for all your help:) Patient programmer's like yourself, who help those of us who are trying to learn the language -really are a godsend. Will try out your pointers this very evening and I'm sure it will turn out just fine. Finishing this goal will allow me to finally move on to the next phase of my education in C++.
Thanks again!
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

785 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