|
This walkthrough explains how to embed and use an ActiveX
control in a Visual Basic 6.0 project. Before starting, you
must have the ActiveX control you intend to use registered
with your computer. For this walkthrough, I will be using
an Animated Gif control called MVSGif.ocx.
Step 1 - Import ActiveX Control
Before an ActiveX control can be embedded into your project,
it must be imported into the toolbar. This can be done by
selecting 'Project' - 'Components', and then checking the
box designating the desired control.

Afterwards, a new control should appear at the end of the
toolbar, showing success of the import procedure.
Step 2 - Add ActiveX Control
With the new control added to the toolbar, you may add the
control by selecting it from the toolbar, and then drawing
it into your project. After being drawn, the control can be
visually manipulated within the project, such as changing
its size or position. In the case of the Animated Gif, the
control itself is invisible until a .gif image is loaded.
The only hint that our project contains the Animated Gif control
is the blue border outline shown after it is clicked on.

Step 3 - Invoke ActiveX Control Methods
After the control is added, positioned, and sized, one must
implement a way to invoke the control's methods and/or handle
the events that it fires. The simplest way to handle an event
is by direct modification within the "Code View"
of the project.

Within the code view of a project, the ActiveX control may
be selected in the drop-down list for controls, which is the
left-side list.

After selecting the control, the events that you wish to
react to may be selected within the right drop-down list,
which handles the events of the control listed in the left-side
list.

Step 4 - Add Code
As soon as an event is chosen to be handled, Visual Basic
will automatically generate a Sub heading. All that is left
to do is to add code! In this example, I am choosing to invoke
the "Play" method of the ActiveX control whenever
the user releases the right mouse button over the control.
|