Solved

Cancelling a deactivation event in an MDI form

Posted on 2004-09-23
5
440 Views
Last Modified: 2008-02-01
I have a windows MDI application. Before a child form is deactivated I would like to check values on the form and prevent the deactivation if the values are incorrect.

I am able to prevent
  -Closing the child form by cancelling the closing event
  -Navigating records within the child form
  -Actions associated with the child form buttons

I need advice on how to abort the following actions when I discover incorrect values on the current child form:
  -selection of another MDI child window
  -selecting menu items of the parent form
  -closing the parent form

In other words, I would like the original child form to behave as though I had cancelled its deactivation event (I understand there is no "Deactivating" event which would allow a cancel)
0
Comment
Question by:pgormley
  • 3
  • 2
5 Comments
 
LVL 20

Expert Comment

by:TheAvenger
ID: 12140745
There is a Deactivate event for the form. The problem is that you will have to activate the form again, which may make some unpleasant blinking:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformsformclassdeactivatetopic.asp
0
 

Author Comment

by:pgormley
ID: 12151670
Hi Avenger,

I know about the deactivate event. The problem is it is raised prior to the activate event for another form if I select another form. For example, if I there is an error on Form1 which is currently active and I click on Form2, I need to prevent the activation of form2. Form1.Activate() in Form1's deactivate event will not solve this.
0
 
LVL 20

Accepted Solution

by:
TheAvenger earned 125 total points
ID: 12151682
You can set a flag and then when the form2 is activate (so in its activate event) reactivete form1
0
 

Author Comment

by:pgormley
ID: 12152456
Problem is there are four other forms and about 15 menu items that would all have to have extra error checking code to send control back to the problem form. It sounds like you are saying there is no way to prevent a form from activating or a menu item from executing from within a problem form's deactivation event. Right?
0
 
LVL 20

Expert Comment

by:TheAvenger
ID: 12152462
Well, that's the only idea that occurs to me. Maybe there is a better one, but I cannot think of one....
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now