
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