?
Solved

Conditionally allow creation of new Child Frames in an MDI application using MFC

Posted on 2004-04-15
5
Medium Priority
?
284 Views
Last Modified: 2013-11-20
Hello,

I have written an MDI application using Visual C++ and MFC 6 with Doc/View support. The UI is like this: MDI App with each Child Frame divided into 2 Views with a SplitterWnd, first one a CEditView derived class where the user can enter any Sql query. Second, a CView derived class where the results of the query are displayed in a child Grid control which resizes fully to cover the parent view. This is what I want to accomplish:

When the user chooses File->New (CWinApp::OnFileNew()), I want to present a modal dialog with UserName,Password and a list of valid Dsn's. If the connection is succussfully, allow the framework to create the new child frame with the 2 Views, if he clicks cancel, the new child frame with the 2 views should not be created. I have created the dialog and tested it, no issues there.

I want to know where to put code so that the I can stop the MFC architechture from creating the new child frame when the validation fails. Please help me out in this regard.

Thanks,

Balaji
0
Comment
Question by:BalajiS
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 500 total points
ID: 10831016
In MDI application created by MFC Application Wizard there is the following line:

ON_COMMAND(ID_FILE_NEW, OnFileNew)

in the application class message map. You need to provide your own message handler:

afx_msg void OnMyFileNew( );      // in h-file


ON_COMMAND(ID_FILE_NEW, OnMyFileNew)        // in message map, instead of ON_COMMAND(ID_FILE_NEW, OnFileNew)


Implementation:

void CMyApp::OnMyFileNew()
{
    // Show dialog here
    // If succeeded, call CWinApp::OnFileNew();
    // which actually creates new frame
}




0
 

Author Comment

by:BalajiS
ID: 10841154
Thanks a lot for your valuable suggestion. I did the same for OnFileOpen and it works fine.

The only issue remaining is that how do I tackle MRU menu items. I understand MFC uses a pre-wired handler for ID_FILE_MRU_1 and opens the document dyanmically from the selection. Can I handle this too ?

Balaji
0
 

Author Comment

by:BalajiS
ID: 11124126
That's ok, you can close the question. I have been able to solve it completely.

Thanks,

Balaji
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses

752 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