Change file index filter of the standard file open/save dialog 
Author Message
 Change file index filter of the standard file open/save dialog

Hi to you all!

I would like to change the standard
file index filter in the standard file
open/save dialog.

Who can help me?

Thanks a lot.



Sat, 09 Jul 2005 09:40:53 GMT  
 Change file index filter of the standard file open/save dialog
I'd like to complete that
I'm working in the SDI app.


Sat, 09 Jul 2005 09:45:14 GMT  
 Change file index filter of the standard file open/save dialog

Try something along the following lines..

         CFileDialog dlg(true);
        dlg.m_ofn.lpstrFilter = TEXT("Text
Files\0*.TXT\0Assembly\0*.asm\0Cpp\0*.cpp\0\0");
        dlg.m_ofn.nFilterIndex = 2;

        dlg.DoModal();

--
Cheers
Check Abdoul [ VC++ MVP ]
-----------------------------------


Quote:
> Hi to you all!

> I would like to change the standard
> file index filter in the standard file
> open/save dialog.

> Who can help me?

> Thanks a lot.



Sat, 09 Jul 2005 15:51:32 GMT  
 Change file index filter of the standard file open/save dialog
Thanks!

But how (where) can I insert this code (to)?
Could you please show me how to insert
this code in my SDI application? Sorry beginner.



: Try something along the following lines..
:
:          CFileDialog dlg(true);
:         dlg.m_ofn.lpstrFilter = TEXT("Text
: Files\0*.TXT\0Assembly\0*.asm\0Cpp\0*.cpp\0\0");
:         dlg.m_ofn.nFilterIndex = 2;
:
:         dlg.DoModal();
:
: --
: Cheers
: Check Abdoul [ VC++ MVP ]
: -----------------------------------
:
:

: > Hi to you all!
: >
: > I would like to change the standard
: > file index filter in the standard file
: > open/save dialog.
: >
: > Who can help me?
: >
: > Thanks a lot.
: >
: >
:
:



Sat, 09 Jul 2005 17:01:56 GMT  
 Change file index filter of the standard file open/save dialog

Quote:

> Thanks!

> But how (where) can I insert this code (to)?
> Could you please show me how to insert
> this code in my SDI application? Sorry beginner.

Hi Nassau,
By default the file open command is handled by CWinApp::OnFileOpen.
What you can do is add your own message handler for the file open
command and display the file open dialog yourself, with the filtering
you want.  

BEGIN_MESSAGE_MAP(CPlainSDIApp, CWinApp)
        //{{AFX_MSG_MAP(CPlainSDIApp)
        ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
        ON_COMMAND(ID_FILE_OPEN, OnFileOpen)  // ADDED
        //}}AFX_MSG_MAP
        // Standard file based document commands
        ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
//      ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) // REMOVED
        // Standard print setup command
        ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()

I commented out the default OnFileOpen line and the wizard added the
ADDED line when I added a message handler for ID_FILE_OPEN.  So now the
menu command will come to your own OnFileOpen.  It should look something
like this:

void CPlainSDIApp::OnFileOpen()
{
 CFileDialog dlg(true);
 dlg.m_ofn.lpstrFilter = TEXT("Text
Files\0*.TXT\0Assembly\0*.asm\0Cpp\0*.cpp\0\0");
 dlg.m_ofn.nFilterIndex = 2;
 if (dlg.DoModal() == IDOK)
        OpenDocumentFile(dlg.GetPathName());

Quote:
}

--
Scott McPhillips [VC++ MVP]


Sat, 09 Jul 2005 21:17:26 GMT  
 Change file index filter of the standard file open/save dialog
Many many thanks to you! Now I can go on.

Greetings!



: >
: > Thanks!
: >
: > But how (where) can I insert this code (to)?
: > Could you please show me how to insert
: > this code in my SDI application? Sorry beginner.
:
: Hi Nassau,
: By default the file open command is handled by CWinApp::OnFileOpen.
: What you can do is add your own message handler for the file open
: command and display the file open dialog yourself, with the filtering
: you want.
:
: BEGIN_MESSAGE_MAP(CPlainSDIApp, CWinApp)
: file://{{AFX_MSG_MAP(CPlainSDIApp)
: ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
: ON_COMMAND(ID_FILE_OPEN, OnFileOpen)  // ADDED
: file://}}AFX_MSG_MAP
: // Standard file based document commands
: ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
: // ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) // REMOVED
: // Standard print setup command
: ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
: END_MESSAGE_MAP()
:
: I commented out the default OnFileOpen line and the wizard added the
: ADDED line when I added a message handler for ID_FILE_OPEN.  So now the
: menu command will come to your own OnFileOpen.  It should look something
: like this:
:
: void CPlainSDIApp::OnFileOpen()
: {
:  CFileDialog dlg(true);
:  dlg.m_ofn.lpstrFilter = TEXT("Text
: Files\0*.TXT\0Assembly\0*.asm\0Cpp\0*.cpp\0\0");
:  dlg.m_ofn.nFilterIndex = 2;
:  if (dlg.DoModal() == IDOK)
: OpenDocumentFile(dlg.GetPathName());
: }
:
: --
: Scott McPhillips [VC++ MVP]



Sun, 10 Jul 2005 21:33:22 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Multiple Filters in File Open/Save Dialog

2. HOW TO Filter Files Without File Extention in Open File Dialog Box

3. File extension filtering for the file dialog presented for file opening

4. changing the default file extension in the file open dialog box

5. Changing file types in File open dialog

6. changing file open filter string

7. filtered open file dialog

8. File dialog of Open/Save

9. File Open / Save As dialog overriding

10. Customized File Open/Save Dialog problem

11. Common Dialogs File Open, Save As

12. Beginner [Q] Using Canned File Open/Save dialog

 

 
Powered by phpBB® Forum Software