Solved

remove items from CFileDialog

Posted on 1998-09-02
11
395 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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

760 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

20 Experts available now in Live!

Get 1:1 Help Now