Solved

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

Posted on 2004-04-15
5
272 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 125 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

Technology Partners: 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

Suggested Solutions

Title # Comments Views Activity
not able to insert into temp table 68 178
string initialization in java 11 122
Thin secure Windows 10 5 116
Windows shortcut location resolution on double click open 4 77
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

732 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