Solved

Customization of File Open Dialog????

Posted on 1997-04-27
7
446 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 Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Separate into files by filename 12 75
ORA-01403: no data found 43 89
how to monitor remote shell execution on linux 9 97
isEverywhere  challenge 19 70
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

937 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

9 Experts available now in Live!

Get 1:1 Help Now