Previous | Index | Next 

[PRB] Invoking the Show method of MDI child forms containing one or more ActiveX controls might not fire the Load event

When an MDI child form hosts one or more ActiveX controls, in certain cases this control prevents the form’s Load event from firing when the form is displayed by means of the Show method. We are investigating this problem, but in the meantime here are a few workarounds.

The simplest solution is that you host the ActiveX control inside a container, such as a Frame or a PictureBox control. In such a case, the Load event fires correctly.

Another simple workaround: you explicitly load the form before showing it. You can do it via an InsertStatement pragma, so that the VB6 code isn’t affected;

         '## InsertStatement Load6(frmChildMDI)

A minor problem with this workaround is that the Load event fires after the form has already become visible. To avoid this side-effect you can proceed as follows: set the MdiChild property to False before invoking the Show method and assign the MdiParent property inside the Form_Load event hander:

         ' in the main application
         Private Sub cmdShowForm_Click()
  '## InsertStatement frmChild1.MdiChild = False
  End Sub   ' inside the MDI child form   Private Sub Form_Load() Handles MyBase.Load
  '## InsertStatement Me.MdiParent = VB6MdiForm.Instance
  End Sub


Previous | Index | Next