Trust the Activate and Deactivate events????

  • Thread starter Thread starter active
  • Start date Start date
A

active

I remember when I checked NewGroups for comments about the VB6 Activate
event and found that many thought it was not a reliable way to keep track of
which form has focus. There was enough bad press that I avoided it.

I now have a project with MDI child forms and non-MDI child forms coming and
going as the user selects different options. I need to know which form is
the active one and thought that I could use the Activate and Deactivate
events to maintain a global variable that could be checked as needed.

Before I put forth the effort I thought I'd check to see if anyone had
experience using those events and/or had any helpful suggestions.


Cal
 
Hello, active:

The Activate event occurs before the former object has lost the focus.
You can understand how and when a control gets and losts the focus in the Enter event topic:
http://msdn.microsoft.com/library/d...fsystemwindowsformscontrolclassentertopic.asp.

Although its not perfectly explained, I think. I understand it means:
(NewControl is the control that receives the focus, OldControl is the one that looses it)
<PASTE>
When you change the focus by using the keyboard (TAB, SHIFT+TAB, and so on), by calling the Select or SelectNextControl methods, or by setting the ContainerControl.ActiveControl property to the current form, focus events occur in the following order:

1.. NewControl.Enter or Activated
2.. NewControl.GotFocus
3.. OldControl.Leave or Deactivate
4.. OldControl.Validating
5.. OldControl.Validated
6.. OldControl.LostFocus
When you change the focus by using the mouse or by calling the Focus method, focus events occur in the following order:

1.. NewControl.Enter or Activated
2.. NewControl.GotFocus
3.. OldControl.LostFocus
4.. OldControl.Leave or Deactivate
5.. OldControl.Validating
6.. OldControl.Validated
If the CausesValidation property is set to false for OldControl, the Validating and Validated events are suppressed.

</PASTE>


Regards.


" active" <[email protected]> escribió en el mensaje | I remember when I checked NewGroups for comments about the VB6 Activate
| event and found that many thought it was not a reliable way to keep track of
| which form has focus. There was enough bad press that I avoided it.
|
| I now have a project with MDI child forms and non-MDI child forms coming and
| going as the user selects different options. I need to know which form is
| the active one and thought that I could use the Activate and Deactivate
| events to maintain a global variable that could be checked as needed.
|
| Before I put forth the effort I thought I'd check to see if anyone had
| experience using those events and/or had any helpful suggestions.
|
|
| Cal
|
|
 
Thanks

Cal

"José Manuel Agüero" <jmaguero_vodafone.es> wrote in message
Hello, active:

The Activate event occurs before the former object has lost the focus.
You can understand how and when a control gets and losts the focus in the
Enter event topic:
http://msdn.microsoft.com/library/d...fsystemwindowsformscontrolclassentertopic.asp.

Although its not perfectly explained, I think. I understand it means:
(NewControl is the control that receives the focus, OldControl is the one
that looses it)
<PASTE>
When you change the focus by using the keyboard (TAB, SHIFT+TAB, and so on),
by calling the Select or SelectNextControl methods, or by setting the
ContainerControl.ActiveControl property to the current form, focus events
occur in the following order:

1.. NewControl.Enter or Activated
2.. NewControl.GotFocus
3.. OldControl.Leave or Deactivate
4.. OldControl.Validating
5.. OldControl.Validated
6.. OldControl.LostFocus
When you change the focus by using the mouse or by calling the Focus method,
focus events occur in the following order:

1.. NewControl.Enter or Activated
2.. NewControl.GotFocus
3.. OldControl.LostFocus
4.. OldControl.Leave or Deactivate
5.. OldControl.Validating
6.. OldControl.Validated
If the CausesValidation property is set to false for OldControl, the
Validating and Validated events are suppressed.

</PASTE>


Regards.


" active" <[email protected]> escribió en el mensaje
| I remember when I checked NewGroups for comments about the VB6 Activate
| event and found that many thought it was not a reliable way to keep track
of
| which form has focus. There was enough bad press that I avoided it.
|
| I now have a project with MDI child forms and non-MDI child forms coming
and
| going as the user selects different options. I need to know which form is
| the active one and thought that I could use the Activate and Deactivate
| events to maintain a global variable that could be checked as needed.
|
| Before I put forth the effort I thought I'd check to see if anyone had
| experience using those events and/or had any helpful suggestions.
|
|
| Cal
|
|
 
That's good to know. I probable would have set a variable to Nothing in
Deactivate and to the form in Activate, but I can see now I better do
nothing in Deactivate or check to make sure the variable is referencing the
form deactivating before I set it to Nothing.

The Activate event occurs before the former object has lost the focus.
You can understand how and when a control gets and losts the focus in the
Enter event >topic:
 
Back
Top