Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2004-04-15
5
Medium Priority
?
294 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

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…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

610 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