By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,689 Members | 1,759 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,689 IT Pros & Developers. It's quick & easy.

Trust the Activate and Deactivate events????

P: n/a
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
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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/de...entertopic.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" <ac****@REMOVEa-znet.com> escribió en el mensaje news:%2****************@tk2msftngp13.phx.gbl...
| 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
|
|
Nov 20 '05 #2

P: n/a
Thanks

Cal

"José Manuel Agüero" <jmaguero_vodafone.es> wrote in message
news:e0**************@TK2MSFTNGP12.phx.gbl...
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/de...entertopic.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" <ac****@REMOVEa-znet.com> escribió en el mensaje
news:%2****************@tk2msftngp13.phx.gbl...
| 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
|
|
Nov 20 '05 #3

P: n/a
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:
Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.