Solved

Revisiting the predefined saveas/open dialog box

Posted on 1998-08-18
4
193 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

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…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

785 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