The information in this article applies to:
- Microsoft Visual Basic Learning, Professional, and Enterprise Editions
for Windows, version 5.0
SYMPTOMS
An ActiveX control is created using Visual Basic and compiled into an OCX
file. The compiled OCX is then referenced in a Visual Basic standard EXE
project. When the standard EXE project is run in the IDE, tabbing between
the controls on the form and the ActiveX control results in a beep and the
focus does not change. This problem occurs after the ActiveX control has
shown a modal form.
RESOLUTION
This problem only occurs when a project in the IDE references the compiled
OCX; the problem does not occur when the project is made into an EXE.
To work around this problem, create a project group and reference the
ActiveX control from the ActiveX control project. Reference the compiled
version of the ActiveX control just before you compile your Visual Basic
project.
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 section show you how to create a sample project that demonstrates this
behavior.
Steps to Create the ActiveX control
- Start a new ActiveX Control project in Visual Basic. UserControl1 is
created by default.
- Add a textbox to UserControl1.
- Copy the following code to the Code window of UserControl1:
Option Explicit
Private Sub Text1_DblClick()
Form1.Show vbModal
End Sub
- Add a form to the ActiveX control project.
- Add a CommandButton to Form1. Copy the following code to the Code
window of Form1:
Option Explicit
Private Sub Command1_Click()
Unload Me
End Sub
- Change the Project name to "TestControl" and select the File/Make
TestControl.ocx menu option to create TestControl.ocx. After
creating the control, save and close the project.
You are done creating the ActiveX control. The next section shows you how
to create the Standard EXE project that uses the ActiveX control you just
created.
Steps to Create Standard EXE Project
- Start a new Standard EXE project in Visual Basic. Form1 is created by
default.
- Add an MDI Form to the project.
- Set the MDIChild property of Form1 to True.
- Reference the ActiveX control you compiled in the previous section by
completing the following steps:
a. From the Project menu, click Components. The Components dialog box
displays.
b. Select the Controls Tab. Check TestControl in the list box.
c. Click OK to close the Components dialog box.
- Add two instances of the TestControl ActiveX control to Form1.
Position the two ActiveX controls so both controls are visible on the
form.
- On the Run menu, click Start, or press the F5 key to start the program.
a. Press the Tab key to change the focus between the two controls.
b. Double-click the text box on one of the TestControl ActiveX controls.
Form1 appears. Click the CommandButton to close the form.
c. Set the focus to one of the TestControl ActiveX controls.
RESULTS: Pressing the Tab key results in a beep and the focus does not
change.
The next section shows how to work around this bug using the projects you
created in the previous sections.
Workaround
- Open the ActiveX control project you used to create the ActiveX control.
- From the File menu, click Add Project to add a standard EXE project.
Form1 is created by default. Set the MDIChild property of Form1 to true.
- Close the ActiveX control project. Note than an ActiveX control is added
to the toolbar.
- Add two instances of the ActiveX control to Form1. Position the two
ActiveX controls so both controls are visible on the form.
- On the Run menu, click Start or press the F5 key to start the program.
a. Press the Tab key to change the focus between the two controls.
b. Double-click the text box on one of the TestControl ActiveX controls.
A form is displayed. Click the CommandButton to close the form.
c. Set the focus to one of the TestControl ActiveX controls.
You can now tab between the text boxes of both ActiveX controls.