Solved

remove items from CFileDialog

Posted on 1998-09-02
11
404 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

828 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