Saturday, 9 March 2013

ActiveX Controls


ActiveX Controls

ActiveX controls are tiny little Automation servers that load in process. This means
they are remarkably fast. They were originally called OLE Custom Controls and were
designed to replace VBX controls, 16-bit controls written for use in Visual Basic and
Visual C++. (There are a number of good technical reasons why the VBX technology
could not be extended to the 32-bit world.) Because OLE Custom Controls were
traditionally kept in files with the extension .OCX, many people referred to an OLE
Custom Control as an OCX control or just an OCX. Although the OLE has been
supplanted by ActiveX, ActiveX controls produced by Visual C++ 6.0 are still kept in
files with the .OCX extension.
The original purpose of VBX controls was to allow programmers to provide unusual
interface controls to their users. Controls that looked like gas gauges or volume knobs
became easy to develop. But almost immediately, VBX programmers moved beyond simple
controls to modules that involved significant amounts of calculation and processing. In
the same way, many ActiveX controls are far more than just controls; they are
components that can be used to build powerful applications quickly and easily.
NOTE: If you have built an OCX in earlier versions of Visual C++, you might
think it is a difficult thing to do. The Control Developer Kit, now
integrated into Visual C++, takes care of the ActiveX aspects of the job and
allows you to concentrate on the calculations, display, or whatever else it
is that makes your control worth using. The ActiveX Control Wizard makes
getting started with an empty ActiveX control simple.
Because controls are little Automation servers, they need to be used by an Automation
controller, but the terminology is too confusing if there are controls and controllers,
so we say that ActiveX controls are used by container applications. Visual C++ and
Visual Basic are both container applications, as are many members of the Office suite
and many non-Microsoft products.
In addition to properties and methods, ActiveX controls have events. To be specific, a
control is said to fire an event, and it does so when there is something that the
container needs to be aware of. For example, when the user clicks a portion of the
control, the control deals with it, perhaps changing its appearance or making a
calculation, but it may also need to pass on word of that click to the container
application so that a file can be opened or some other container action can be
performed.

This chapter has given you a brief tour through the concepts and terminology used in
ActiveX technology, and a glimpse of the power you can add to your applications by
incorporating ActiveX into them. The remainder of the chapters in this part lead you
through the creation of ActiveX applications, using MFC and the wizards in Visual C++.

No comments:

Post a Comment