Solved

Customization of File Open Dialog????

Posted on 1997-04-27
7
442 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

757 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

18 Experts available now in Live!

Get 1:1 Help Now