Solved

Customization of File Open Dialog????

Posted on 1997-04-27
7
455 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
Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Expand data scrubbing tool 13 32
viewing source code from eclipse 13 106
Problem to event 3 96
unix example issues 18 90
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…
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…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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.

772 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