Solved

Cancelling a deactivation event in an MDI form

Posted on 2004-09-23
5
445 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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
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 Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

770 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