PRB: Activate Event Is Not Triggered with Child Form of MDI Form (190634)
The information in this article applies to:
- Microsoft Visual Basic Professional Edition for Windows 5.0
- Microsoft Visual Basic Professional Edition for Windows 6.0
- Microsoft Visual Basic Enterprise Edition for Windows 5.0
- Microsoft Visual Basic Enterprise Edition for Windows 6.0
This article was previously published under Q190634 SYMPTOMS
The Activate event for an MDIChild form is only triggered the first time
the form is shown. For example, when an MDIChild form is displayed using
the Show Method, then hidden using the Hide method, and then shown again
using the Show method, the Activate event is triggered only the first time
the form is shown.
CAUSE
The Activate and Deactivate events occur for MDI child forms only when the
focus changes from one child form to another. In an MDIForm object with two
child forms, the child forms receive these events when the focus moves
between them. However, when the focus changes between a child form and a
non-MDI child form, the parent MDIForm receives the Activate and Deactivate
events.
RESOLUTION
To work around this behavior, create a custom method in Form1 to handle
showing the form. In the custom method, place code to show the form as well
as code you would have placed in the Activate event. To display the child
form, call the custom method instead of using the form's Show method. An
example custom method to show a child form and simulate an Activate event
would be:
Public Sub MyShow()
Form1.Show
MsgBox "MyShow - simulation of Activate event"
End Sub
The call to invoke this custom method would be:
Form1.MyShow 'Call the custom method created in Form1
STATUS
This behavior is by design.
REFERENCES
For documentation on this behavior, search for "Activate event" in Visual
Basic Online Help Index. Select "Activate,Deactivate Events."
Modification Type: | Minor | Last Reviewed: | 1/8/2003 |
---|
Keywords: | kbprb KB190634 |
---|
|