Solved

remove items from CFileDialog

Posted on 1998-09-02
11
397 Views
Last Modified: 2013-11-20
hi,
I wrote a class derived from CFileDialog. I added some
controls to the dialog ( buttons ... ):

m_ofn.Flags |= (OFN_EXPLORER | OFN_ENABLETEMPLATE);
m_ofn.lpTemplateName = MAKEINTRESOURCE( IDD_MYDLG /*my
dialog additional controls*/ );

Now I want to remove some items ( e.g. the Ok button ) from
the dialog.
How to do this?

regards nil

0
Comment
Question by:nil092297
  • 5
  • 4
  • 2
11 Comments
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1321623
I do not believe that is possible using the standard CFileDialog class.  Perhaps if you derived a class from it.
0
 

Author Comment

by:nil092297
ID: 1321624
I have derived my class from CFileDialog!
Or is it possible to hide the button?
0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1321625
But if you want to remove some items and change the overall appearance look into the m_ofn member variable (the only member variable that you can access).
0
 
LVL 1

Accepted Solution

by:
rlarner earned 200 total points
ID: 1321626
Each of the items in a file dialog has an ID, which you can then hide.
Check out www.codeguru.com, they have examples in the dialog section (specifically the file dialogs that only display directories)

0
 

Author Comment

by:nil092297
ID: 1321627
I tried
GetDlgItem( IDOK )->ShowWindow( SW_HIDE );
but this one chrashes because m_hWnd is NULL ...
I looked at www.codeguru.com but the classes they have, and that are derived
from CFileDialog, have all the (standard) items plus additional controls.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Expert Comment

by:rlarner
ID: 1321628
You have to make the call in the OnInitDone method in your derived class.  Also, call HideWindow, not GetDlgItem()->ShowWindow(), since the window exists outside of your app's space.
0
 

Author Comment

by:nil092297
ID: 1321629
There is no function called HideWindow!?
0
 
LVL 1

Expert Comment

by:rlarner
ID: 1321630
Whoops!  I mistyped.  It should be: HideControl.
try downloading:
http://www.codeguru.com/dialog/folder_dialog_source.zip
It has two files.  The folder_dialog.cpp file contains an example of hiding the IDOK control.  HideDialog is an undocumented call in CFileDialog, that sends the CDM_HIDECONTROL message (which you can lookup in help).  Also try searching your help for edt1 - it will give you the description of the controls that you can hide with CDM_HIDECONTROL.
0
 
LVL 1

Expert Comment

by:rlarner
ID: 1321631
Wow, I must be off today -- that or in a hurry.  The example above doesn't actually hide the OK button, but it does hide some of the other controls.  Just use IDOK instead of, say, edt1 (which the code does show how to hide), and it should work fine.
0
 

Author Comment

by:nil092297
ID: 1321632
Ok
works fine :)
0
 

Author Comment

by:nil092297
ID: 1321633
Ok
works fine :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
not able to insert into temp table 68 157
Generic progress indicator 6 113
matchUp  challenge 6 53
Annoying "thing" blocks my view 4 82
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

895 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

14 Experts available now in Live!

Get 1:1 Help Now