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

x
?
Solved

C++ how to serialize with options?

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

Accepted Solution

by:
chensu earned 200 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
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.

971 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