Solved

remove items from CFileDialog

Posted on 1998-09-02
11
400 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

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

Suggested Solutions

Title # Comments Views Activity
Change owner from userA to server Local Administrators 7 62
string initialization in java 11 113
sum67 challenge 35 97
Message not shown 5 49
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

808 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