Link to home
Start Free TrialLog in
Avatar of BalajiS
BalajiS

asked on

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

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
ASKER CERTIFIED SOLUTION
Avatar of AlexFM
AlexFM

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of BalajiS
BalajiS

ASKER

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
Avatar of BalajiS

ASKER

That's ok, you can close the question. I have been able to solve it completely.

Thanks,

Balaji