Solved

Customization of File Open Dialog????

Posted on 1997-04-27
7
464 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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
Expand macro to ask for filename column 8 37
only14 challenge 19 84
java ^ examples 8 70
Path of Workbook 3 87
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…
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…
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.

733 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