Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Customization of File Open Dialog????

Posted on 1997-04-27
7
460 Views
Last Modified: 2013-11-20
Could somebody tell me as to whether it is possible to customize the MFC's common File Dialog
such that, on triggering, it displays only the FOLDERS from the current directory and not the FILES????
I have referred a couple of books, but couldn't find a pointer on how to go abt doing it.
Any help would be appreciated..  Thanx in Advance
Dilip
0
Comment
Question by:janus042597
  • 4
  • 2
7 Comments
 
LVL 2

Expert Comment

by:rajesh032097
ID: 1301197
Hi,
You can get a sample for this in DIRPK example on ftp://ftp.microsoft.com/ Softlib\Mslfiles directory.
If you have any problems, please get back to me.

0
 

Author Comment

by:janus042597
ID: 1301198
Hi Mr. Rajesh

I went to the ftp directory you mentioned (softlib/mslfiles).
But I couldn't find any reference to the file you had mentioned
(DIRPK).  There is neither a file nor a directory in the name of DIRPK.
Thanx for the effort ......
Dilip
0
 
LVL 1

Expert Comment

by:jmmougeolle
ID: 1301199
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

 

Author Comment

by:janus042597
ID: 1301200
Sorry Mr. Jmmougeolle, the file (DIRPK.EXE) is not to be found even in the directory u mentioned.  Here is the complete listing of the directory ftp.microsoft.com/Softlib;

Mslfiles (directory); README.TXT; SOFTLIB.EXE; WDL.TXT; WNTDL.TXT

These are the only 5 listings I found in the place you mentioned.
There was no sign of DIRPK.EXE ..........
Thanx for the effort though......

Dilip



0
 
LVL 2

Accepted Solution

by:
rajesh032097 earned 50 total points
ID: 1301201
Hi,
If you are not able to find that sample, I will mention briefly what is to be done :
1. Follow the instructions given in "Directory Picker Sample Using Modified CFileDialog" article in Knowledge base section of VC++ documentation. Hope you will find that.
Then, in OnInitDialog() of your class derived from CFileDialog,
do following steps :
CMyFileDialog::OnInitDialog()
{  
// This is for showing/hiding the unneeded controls on the CFileDialog template
        GetDlgItem(stc2)->ShowWindow(SW_HIDE);
      GetDlgItem(stc3)->ShowWindow(SW_HIDE);
      GetDlgItem(edt1)->ShowWindow(SW_HIDE);
      GetDlgItem(lst1)->ShowWindow(SW_HIDE);
      GetDlgItem(cmb1)->ShowWindow(SW_HIDE);

 // edt1 is the ID of edit control in the file dialog which //displays the name. So first it's made invisible ( by SW_HIDE ) //and then set       any value so that file dialog gets dismissed when //OK button is clicked.
      SetDlgItemText(edt1, "Junk");
      GetDlgItem(lst2)->SetFocus();

      CFileDialog::OnInitDialog();

      
      return FALSE;  // return TRUE unless you set the focus to       a control
}

Then in the handler for your customised dialog, you can get the directory path as follows:
CMyApp::OnCustomizedFileDialog()
{
  if (IDOK==cfdlg.DoModal())
    {
     CMyFileDlg  cfdlg(FALSE, NULL, NULL, OFN_SHOWHELP |          OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_ENABLETEMPLATE,      NULL, m_pMainWnd);

       WORD wFileOffset;
       char szBuffer[128];
   
       wFileOffset = cfdlg.m_ofn.nFileOffset;  //for convenience

       cfdlg.m_ofn.lpstrFile[wFileOffset-1]=0; //Nuke the "Junk"

       wsprintf(szBuffer, "Selected directory is %s",
                (LPSTR)cfdlg.m_ofn.lpstrFile);

       AfxMessageBox((LPSTR)szBuffer, MB_OK);
}

You will have to follow the steps carefully for including the template for CFileDialog in your .rc file.
In your class declaration, you have to put following code to inform that you are going to use this template for your file open dialog.
enum { IDD = IDD_NEWFILEOPEN};
Hope this clarifies your problem. I have given almost all the code from the DIRPK sample itself, so there shouldn't be much problem.

0
 
LVL 2

Expert Comment

by:rajesh032097
ID: 1301202
There is a slight mistake in the code provided in my answer. You might have been able to make it out :
The line
CMyFileDlg cfdlg(FALSE, NULL, NULL, OFN_SHOWHELP | OFN_HIDEREADONLY |OFN_OVERWRITEPROMPT | OFN_ENABLETEMPLATE, NULL, m_pMainWnd);
should be before
if (IDOK==cfdlg.DoModal())
Please take a note of that.
0
 
LVL 2

Expert Comment

by:rajesh032097
ID: 1301203
There is a slight mistake in the code provided in my answer. You might have been able to make it out :
The line
CMyFileDlg cfdlg(FALSE, NULL, NULL, OFN_SHOWHELP | OFN_HIDEREADONLY |OFN_OVERWRITEPROMPT | OFN_ENABLETEMPLATE, NULL, m_pMainWnd);
should be before
if (IDOK==cfdlg.DoModal())
Please take a note of that.
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

Suggested Solutions

Title # Comments Views Activity
Decoding 32 bit binary streams 6 49
Named range not carried over 10 65
either24  challenge 19 101
I could not set window to top 4 21
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

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