You are on page 1of 13

ActiveX Controls

Introduction

Creating an ActiveX Control

ActiveX Control Functionality

Registering ActiveX

Embedding ActiveX in I.E

Callings Methods of ActiveX

Presentation

Product Engineering & R&D| Global Business Expansion| Global Implementation &Support | Consulting & Advisory Services

8/9/15
NTIL Confidential

Introduction
ActiveX is a Microsoft-created technology that enables different software
applications to share information and functionality.
ActiveX only works with Microsoft applications like Word, Excel, Internet
Explorer and PowerPoint, and will only work on a computer running the
Windows operating system.
ActiveX controls are small applications written in common programming
languages like Visual Basic and C++.

8/9/15

NTIL Confidential

Why and when do we need ActiveX


Control?
The idea behind ActiveX is that software applications don't need to be built from
scratch.
For e.g.
o

8/9/15

Internet Explorer, the default web browser for windows operating system
comes pre-loaded with an ActiveX control that allows for Windows Media
files to be played directly in the Web page.
Another common ActiveX control plays Flash files (.swf). Internet Explorer
can't play Flash files by itself.

NTIL Confidential

How to create an ActiveX Control?


The wizard has created the following three classes:
o MyActXControl This is the ActiveX application class derived from
COleControlModule. It is the base class to derive an OLE control
module object that contains the member functions for initialization
(InitInstance) and code clean up (ExitInstance).
o MyActXControlCtrl This is derived from the base class COleControl.
This is where we will implement most of the functionality for our control.
o MyActXControlPropPage This is derived from the base class
COlePropertyPage. It is used to manage the property page dialog for
the control. The ActiveX Control Wizard has created a default dialog to
serve as a property page for the control.

8/9/15

NTIL Confidential

ActiveX Control Functionality


A Control is:
o A COM object.
o A User Interface
o Creatable

A Control usually has:


o
o
o
o

8/9/15

Properties, both stock and custom


Event call-backs, both stock and custom
Property change notification
Support for containers: OLE Control and in-place activation

NTIL Confidential

ActiveX Control in Container

container invokes
control's methods

Control
Container

control sends
event notification

properties are
examined and
modified

8/9/15

NTIL Confidential

ActiveX
Control

ActiveX Properties, Methods & Events


An ActiveX control fires events to communicate with its control container. The
container, in return, uses methods and properties to communicate with the control.
Properties are data members of the ActiveX control that are exposed to any
container. Properties provide an interface for applications that contain ActiveX
controls, such as Automation clients and ActiveX control containers.
o ActiveX controls can implement both stock and custom methods and
properties. Class COleControl provides an implementation for stock
properties.

8/9/15

NTIL Confidential

Methods
Methods are similar in usage and purpose to the member functions of a
C++ class.
Adding a method using MSVS 2008 wizard.

8/9/15

NTIL Confidential

Events
ActiveX controls use events to notify a container that something has happened
to the control.
Common examples of events include clicks on the control, data entered using
the keyboard, and changes in the controls state. When these actions occur, the
control fires an event to alert the container.
DECLARE_EVENT_MAP(): An event map is declared by the following macro,
located in the header (.H) file of the control class declaration.

8/9/15

NTIL Confidential

Registering ActiveX
When you distribute a Microsoft Visual application that uses an ActiveX
control (.ocx file), the .ocx file must be registered correctly for it to work
correctly.
o It can be either registered by running Microsoft Visual Studio as
Administrator
OR
o You can use the Microsoft Register Server (Regsvr32.exe) to
register a 32- bit .ocx file manually on a 32-bit operating system.
o The syntax for using Regsvr32.exe is as follows:
Regsvr32 [/u] [/s] <OCX File Name>

8/9/15

10

NTIL Confidential

Embedding ActiveX Control Using


Object Tag
ActiveX can be used in a HTML Web Page with the help of <OBJECT>
Tag.
The tag has the following parameters:
ID = A name for the object. The name should be unique among
all other objects on the page.
CLASSID = A class ID number. Every ActiveX control has a
unique class ID that was encoded into it during development.
The browser uses this number to determine which control to
load.
This number must be exactly correct or the control will not load.
Thus, it is preferable to cut and paste these numbers into your
object tag
8/9/15

11

NTIL Confidential

Calling ActiveX Methods using scripts


and V.B

8/9/15

12

NTIL Confidential

Thank You..

13
8/9/15

NTIL Confidential

You might also like