Solved

Cancelling a deactivation event in an MDI form

Posted on 2004-09-23
5
454 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
[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
  • 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled

739 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