A Weird MFC application!

I have a SDI MFC applicaiton, it runs fine until I add a class (a form class, not a MFC class), when it runs, a small dialog appear with 2 option (in a list box, I suppose)to choose , but it's not the thing I want, how can I get rid of this dialog when the program starts! Thankx
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Can you tell us what the dialog is telling? Do you know at what place in your code this dialog appears?
AndyAinscowFreelance programmer / ConsultantCommented:
Do you have two different views to one document?  It could be asking which you want to use.  If that is the case have a look at the ChkBook MFC sample
tinh911Author Commented:
Yes, I have more than 2 views!
Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.

tinh911Author Commented:
In the method
      m_Splitter.CreateStatic(this, 1, 2);
      m_Splitter.CreateView(0,0,RUNTIME_CLASS(FormView),...);//the one I mention!

After I replace the line:
with this
AnotherView is MFC class derived from CListView!
That dialog still appears when my program starts!
AndyAinscowFreelance programmer / ConsultantCommented:
I assume this dialog is asking which view you want.
The CHKBOOK sample has two views to one document.  There it tells you how to stop this dialog appearing.  

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tinh911Author Commented:
Roshan DavisCommented:

if the program has multiple document templates, CWinApp::OnFileNew will prompt the user with a dialog box asking which type of document to open. The programmer may already know which type of CMultiDocTemplate to use, and therefore may not want to prompt the user because it would be inappropriate in the given context of the application.

Assuming the application was originally created with AppWizard, the undocumented CMultiDocTemplate::OpenDocumentFile function can be used to create a new CMultiDocTemplate based window. There are several steps involved:

Add a CMultiDocTemplate pointer to your CWinApp derived class:

      class CMyApp : public CWinApp

        CMultiDocTemplate* m_pDocTemplate;


NOTE: If you plan to use multiple document types, you must create a CMultiDocTemplate pointer member variable for each document type.

In the call to CWinApp::InitInstance, remove the creation of the CMultiDocTemplate from the call to AddDocTemplate. Set the pointer to point to the new CMultiDocTemplate. Use the pointer to call AddDocTemplate:

      BOOL CMyApp::InitInstance()

        m_pDocTemplate = new CMultiDocTemplate(IDR_TEXTTYPE,




Use the pointer to call CMultiDocTemplate::OpenDocumentFile with a NULL parameter to create the new window. For this example, assume there is a button in a CView window. In the BN_CLICKED handler for the button, we want to create a window based on m_pDocTemplate:

      void CMyView::OnNewWindowButtonClicked()
          CMyApp* pApp = (CMyApp*)AfxGetApp();
This same technique could be used to create a CSingleDocTemplate based window in a Single Document Interface (SDI) application. However, it is not necessary. Because there is only one document template for the application, calling OnFileNew() will create the new window without prompting the user for the type of document.

Rosh :)
Hi tinh911
...As u said it is showing two view classes ( with a "new" dialog box) ..
comment the following line of the view which u do not want to display...


If there are more Document templates added , system ask the user to select which template to use.. this is what happened in your case..

tinh911Author Commented:
I want to thank all of you for your help!
Thank again! :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.