How to remove certain doc types from the file|new dialog box in MDI apps 
Author Message
 How to remove certain doc types from the file|new dialog box in MDI apps

Hi all,

In kind of a newbie in MFC programming and I have a question for you
gurus out there.

I have a MDI app which I use to show different filetypes. Some are
proprietary files that can not be created, and other include text and
bmp files, which can be created ok.

When I select File | New, a dialog box show me a list of all
registered document types. When a user select a file type for which
there is no creation routine, the program crashes as you can imagine.

The fix I use now is to override OnNewDocument() to show a message box
and return without doing nothing. I would like these types of document
not to appear at all in the list. Is there an easy way to do that ?

Thanks in advance

Michel Cherbuliez

----------------------------------------------------
Michel Cherbuliez
Swiss Federal Institute of Technology

----------------------------------------------------



Sat, 25 May 2002 03:00:00 GMT  
 How to remove certain doc types from the file|new dialog box in MDI apps

Quote:

>Hi all,

>In kind of a newbie in MFC programming and I have a question for you
>gurus out there.

>I have a MDI app which I use to show different filetypes. Some are
>proprietary files that can not be created, and other include text and
>bmp files, which can be created ok.

>When I select File | New, a dialog box show me a list of all
>registered document types. When a user select a file type for which
>there is no creation routine, the program crashes as you can imagine.

>The fix I use now is to override OnNewDocument() to show a message box
>and return without doing nothing. I would like these types of document
>not to appear at all in the list. Is there an easy way to do that ?

>Thanks in advance

>Michel Cherbuliez

>----------------------------------------------------
>Michel Cherbuliez
>Swiss Federal Institute of Technology

>----------------------------------------------------

Replace
    ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
in your CWinApp derived class' message map with
    ON_COMMAND(ID_FILE_NEW, OnMyFileNew)
and implement your OnMyFileNew along the lines of MFC's implementation of
CDocManager::OnFileNew. Actually the key is the CNewTypeDlg class and in
particular the CNewTypeDlg::OnInitDialog function. All of these things can be
found in the docmgr.cpp file in the MFC sources. Unfortunately, I don't think
any of this stuff is (a) documented (but see Technical Note 22 in the MFC
Technical Notes) or (b) virtual.

--
Adrian M. Whatley
Universitaet/ETH Zuerich,    (the other Swiss Federal Institute of Technology)
Institut fuer Neuroinformatik,
Winterthurerstrasse 190,
CH-8057 Zuerich, Switzerland.
Phone: +41 1 635 3067  Fax: +41 1 635 3053



Sat, 25 May 2002 03:00:00 GMT  
 How to remove certain doc types from the file|new dialog box in MDI apps
There are strings in your resource file that MFC uses to populate the
File|New dialog box.  The documentation for CDocTemplate::GetDocString says
the following:

index
CDocTemplate::fileNewName   Name of this document type. If the application
supports more than one type of document, this string is displayed in the
File New dialog box (for example, "Worksheet"). If not specified, the
document type is inaccessible using the File New command.

To remove the document from File|New, delete the fileNewName string from the
document template string in your resource file; it's named IDR_XXX and
contains a bunch of names separated by newline characters.


Quote:
> Hi all,

> In kind of a newbie in MFC programming and I have a question for you
> gurus out there.

> I have a MDI app which I use to show different filetypes. Some are
> proprietary files that can not be created, and other include text and
> bmp files, which can be created ok.

> When I select File | New, a dialog box show me a list of all
> registered document types. When a user select a file type for which
> there is no creation routine, the program crashes as you can imagine.

> The fix I use now is to override OnNewDocument() to show a message box
> and return without doing nothing. I would like these types of document
> not to appear at all in the list. Is there an easy way to do that ?

> Thanks in advance

> Michel Cherbuliez

> ----------------------------------------------------
> Michel Cherbuliez
> Swiss Federal Institute of Technology

> ----------------------------------------------------



Mon, 27 May 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Help on an MDI app with a sub Doc type

2. How to get one menu per Doc type in an MDI app

3. MDI app crashes sometimes when opening new doc

4. shellexecute + control over window of app that handles certain file types

5. New Doc MDI APP

6. Can I have a Dialog Based Window in an MDI non doc/view app

7. How to set file-types in Doc/View File dialogs

8. how copy Doc file to new Doc file?

9. File->New in doc/view doesn't clear doc file name

10. Dialog box pop-up - SDI vs. MDI apps

11. Modeless dialog boxes in MDI app

12. Dialog box pop-ups - SDI vs. MDI apps

 

 
Powered by phpBB® Forum Software