Solved

C++ how to serialize with options?

Posted on 1998-07-22
4
227 Views
Last Modified: 2010-04-01
null
0
Comment
Question by:kittles
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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 shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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 learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

636 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