Solved

Cancelling a deactivation event in an MDI form

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

930 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

16 Experts available now in Live!

Get 1:1 Help Now