Solved

Revisiting the predefined saveas/open dialog box

Posted on 1998-08-18
4
200 Views
Last Modified: 2010-04-01
null
0
Comment
Question by:kittles
  • 3
4 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 50 total points
ID: 1170644
Yes!  use CFileDialog.  You aren't asking for any capability that isn't already present in CFileDialog.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1170645
You can access the OPENFILENAME structure in the m_ofn member of the CFileDialog object prior to opening the dialog.  In this structure you need to set  the lpstrInitialDir tot he directory you want to default to and lpstrFile to the file name and extension you want to default to.

Let me know if you have questions.
0
 

Author Comment

by:kittles
ID: 1170646
(FALSE,  // TRUE for Open or FALSE Save As
                        NULL,  (is this where I insert the m_OFN member?)
                        NULL,
                        OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
                        NULL,
                        this);  // the parent window is your dialog box

This is my code. From the help documentation this appears to be where I would modify the m_ofn structures you suggested such as lpstrInitialDir & lpszFileName. Is that correct? If so, and I manage to insert the file name I want and the path.. how then do I remove all of the unwanted elements such as the large window where the user choses the file they want, and leave only an edit box for typing in the file name desired? etc. Do I use  dwflags? My documentations says the following:
"dwFlags   A combination of one or more flags that allow you to customize the dialog box. For a description of these flags, see the OPENFILENAME structure in the Win32 SDK documentation. If you modify the m_ofn.Flags structure member, use a bitwise-OR operator in your changes to keep the default behavior intact."

I do not understand the part about a bitwise or operator, and I do not have any win32 sdk documentation that tells me how to do this. The only thing I can find in the MFC library on OPENFILENAME is the different commands to be used to modify the dialog box. Can I use these in the code above? Or must I do more as they suggest above= with the bitwise operator etc?
Thank you very much for answering so quickly & for your patience!


0
 
LVL 22

Expert Comment

by:nietod
ID: 1170647
>> how then do I remove all of the unwanted elements such as the large
>> window where the user choses the file they want, and leave only an
>> edit box for typing in the file name desired?

I didn't realize you wanted to do that.  I beleive that can be done using the lpTemplateName member of the OPENFILENAME structure.  However, I have no experience doing so, if you go really want to go that route you should reject this answer and see what else you can find.  But first consider if that is really a good idea.  Windows tries to present a common interface to the user.  This makes it easier and faster for them to use the software and makes them feel more comfortable.  If you aren't going to follow that interface, you had better have a good reason, one that outweights the issues I just mentioned.

>> I do not understand the part about a bitwise or operator
The | operator is the bitwise or operator.  You can make an integer value that is a combination of flags using | like

OFN_ALLOWMULTISELECT | OFN_ENABLEHOOK
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
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…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

821 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