This walkthrough explains how
to use an ActiveX control in a Visual C++ 6.0 project. Before
you begin you need to have the ActiveX control you intend to
use registered on your computer. For this walkthrough I will
be using an Animated Gif control called MVSGif.ocx.
Step 1 - Add ActiveX Control
Within your project you can insert an ActiveX control by
right-clicking on your program window and selecting "Insert
ActiveX Control."
This will display a dialog for you to select from all of
the registered controls on your computer.

After selecting the "AnimatedGif Control" it is
added to my project and looks like a white box.
Step 2 - Add Member Variable
Now that the control has been added to the project, you need
to add a member variable to represent the control. To do this
go to the Class Wizard (right-click on the program window
and select Class Wizard). In the Class Wizard select the Member
Variables tab and select the control id of the control object
you just added.

Double click on the control ID to bring up the Add Member
Variable dialog. In this dialog set the name for the member
variable, and set the category to Control.

Once the variable has been added, you can use it to invoke
methods or access properties of the control. For example,
my variable is called "m_animatedGif". To call the
"Play" method of the MVSGif control within my program,
I add the line
m_animatedGif.Play();
Step 3 - Add Event Handler
In addition to accessing methods and properties, you can
handle events that are fired by a control. To add an event
handler right-click on the control and select "Events
".
A window will open that allows you to select events to add
to the control from the list of possible events. After the
event handler has been added, you should have a method in
which you can add code for whenever this event is fired by
the control.
|