Solved

C++ how to serialize with options?

Posted on 1998-07-22
4
190 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
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.

708 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

10 Experts available now in Live!

Get 1:1 Help Now