BUG: No Focus When Form Loads in InitProperties/ReadProperties

ID: Q182949

The information in this article applies to:

SYMPTOMS

You open a Form from a UserControl and no object can have the focus. Users cannot click on anything, not even to close the Form.

CAUSE

If a UserControl on a Modal Form opens another Modal Form which was loaded in either the InitProperties or ReadProperties events, no object can have the focus.

RESOLUTION

Do not load a Form modally from the InitProperties or ReadProperties Events of a UserControl on a Modal Form.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

This problem occurs only when using the compiled ocx. Everything works as expected if the UserControl Project is added to this test Project instead of using the compiled ocx. When this problem does occur, the only way to close the Form is from the keyboard by pressing the ALT+F4 key combination. If the BorderStyle property of the Form is set to 0 - None, the process will not work and you cannot close the application gracefully.

Steps to Reproduce Behavior

1. Create a New UserControl Project and name it UsrCtlModalTest.

2. Add a CommandButton to the UserControl, and then add the following code:

      Private Sub Command1_Click()
         usrTestForm.Show vbModal, Me
      End Sub

      Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
      ' or in Sub UserControl_InitProperties ...
         Load usrTestForm
      End Sub

3. Add a Form to the Project and name it usrTestForm. From the File menu,
   Make UsrCtlModalTest.ocx. Close and Save the UserControl Project.

4. Create a New Standard EXE Project. Form1 is created by default. Add a
   second Form to the Project. Add a CommandButton to Form1 with the
   following code:

      Form2.Show vbModal, Me

5. Choose Components from the Project Menu, and then check UsrCtlModalTest
   and OK.

6. Add the UsrCtlModalTest control to Form2. Run the Project and click on
   the buttons to open both Forms.

7. Try to close the last Form by clicking on the Close button in the
   Control Box. Note that no matter where you click, nothing but a beep is
   produced. The only way to close the Form is by pressing the ALT+F4 key
   combination. Once closed and reopened, it works fine. This is because
   you unloaded the instance of the Form that was loaded in either the
   InitProperties or ReadProperties Event. It works fine to Load the Form
   from the Click of the button.

Additional query words: kbActiveX kbVBp500bug kbVBp600bug kbVBp kbdsd kbDSupport kbControl kbCtrlCreate
Platform          : WINDOWS
Issue type        : kbbug
Solution Type     : kbpending

Last Reviewed: August 13, 1998