Solved

C++ how to serialize with options?

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Want to delete all my personal data 13 137
C Language combined operators 28 106
mixing C++ & C# in Vis Studio 2013 7 141
Grammars for C C++ and java 1 114
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
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 tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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…

911 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

22 Experts available now in Live!

Get 1:1 Help Now