Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Cancelling a deactivation event in an MDI form

Posted on 2004-09-23
5
Medium Priority
?
471 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 375 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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…
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.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Screencast - Getting to Know the Pipeline
Suggested Courses

885 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