Wednesday, August 09, 2006

Active X controls: A closer look

Active X controls are a programming technology that allow developers create objects within a programming language that can now be used in a different programming language. The ActiveX object created is often referred to as a component, because it often has to included inside another application to be used.

I'll use an example to illustrate this.
Let's say I'm writing an application in Visual Basic, and the application needs to accept input from users. One of the fields that a user has to enter is a field that they can store their social security number in. Ideally, such a field should only accept input in the following form

###-##-####
where # stands for a number

The problem here is I need to write code to prevent someone from being able to enter:

hel-12-3456

as their social security number. Lets say I know how to write such code in C++ but not in Visual Basic, what I will need to do is go into C++ and create an object that will only accept valid social security numbers. Next, I will return to Visual Basic and embed this object in my application.

The process of doing this is known as OLE (object linking and embedding) and the resulting object that I created is called an ActiveX control or ActiveX component.

To test an ActiveX component, you must warn QTP (and WinRunner) that the application you are testing contains objects that may have been created in a different language. In the case of this example, in addition to inclduing the Visual Basic add-in, we must also include the ActiveX add-in so that the testing tool will know how to interact with our ActiveX object (i.e. the object used to input social security numbers).


For further reading, see:

http://en.wikipedia.org/wiki/ActiveX
http://en.wikipedia.org/wiki/ActiveX_control