Link to home
Start Free TrialLog in
Avatar of hartman2
hartman2

asked on

Save, Open, Print Dialog Boxes

Hello,
I need some help with getting Save, Open, and Print Dialog Boxes to work in an MFC Dialog based program.  Or if this is not possible please let me know.  Thank You.
Avatar of mikeblas
mikeblas

It's quite possible. Just use CFileDialog and CPrintDialog.

.B ekiM


Avatar of hartman2

ASKER

I need to know what the actual code has to be.  Because I am not familiar with that function.
Search the MFC Samples for it.
Where are the MFC Samples
They come with your Visual C++.
To bemore clear I have the code but I don't understand how to set
BOOL bOpenFileDialog
to true or false.
bOpenFileDialog   Set to TRUE to construct a File Open dialog box or FALSE to construct a File Save As dialog box.

ASKER CERTIFIED SOLUTION
Avatar of MaxP
MaxP

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This is an excellent answer.  Thank you very much.
Less than excellent, but thank you anyway. Maybe you should take a look at the documentation for CFileDialog, and its member variables (m_ofn, especially), for a more failsafe and detailed approach.
MaxP
To save data into the file that is created would I just use the serialize command and then the IOstoring command or is there a better/ easier why to do it.
Depends on the kind of data you want to write to your file. Given the FileHandle as in the example above, you might just use WriteFile(FileHandle, etc.). Seems the easiest approach to me if you write e.g. a Bitmap-File.

I am saving text and numbers to the file.  What should I do in your opinion.
I'm really not familiar with serialization, I haven't used it up to now. In my therefore not very expert opinion, it seems a good method for storing objects in a file.
What you seem to be about to do is just store plain data, using your own file format. So, if you're sure about your format (e.g., how will your program know what kind of data is where when it attempts to read the file?), I would probably write it as plain data 'as is'.
I'd recommend to seriously consider the possible variations of reading that file again before deciding how to write it. The data amount shoud be one topic of your considerations, as well as possible write or read errors and how to handle them.
But I'm afraid I can't even guess what could be the best way for you before knowing a few details about your program.