Solved

Revisiting the predefined saveas/open dialog box

Posted on 1998-08-18
4
175 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
Comment Utility
Yes!  use CFileDialog.  You aren't asking for any capability that isn't already present in CFileDialog.
0
 
LVL 22

Expert Comment

by:nietod
Comment Utility
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
Comment Utility
(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
Comment Utility
>> 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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. …
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
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 how to clear a vector as well as how to detect empty vectors in C++.

772 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

10 Experts available now in Live!

Get 1:1 Help Now