The COleControl class is a powerful base class for developing OLE controls. Derived from CWnd, this class inherits all the functionality of a Windows window object plus additional functionality specific to OLE, such as event firing and the ability to support methods and properties.

OLE controls can be inserted into OLE container applications and communicate with the container by using a two-way system of event firing and exposing methods and properties to the container. Note that standard OLE containers only support the basic functionality of an OLE control. They are unable to support extended features of an OLE control. Event firing occurs when events are sent to the container as a result of certain actions taking place in the control. In turn, the container communicates with the control by using an exposed set of methods and properties analogous to the member functions and data members of a C++ class. This approach allows the developer to control the appearance of the control and notify the container when certain actions occur.

Windowless Controls

OLE controls can be used in-place active without a window. Windowless controls have significant advantages:

Controls do not need a window. Services that a window offers can easily be provided via a single shared window (usually the containerís) and a bit of dispatching code. Having a window is mostly an unnecessary complication on the object.

When windowless activation is used, the container (which does have a window) is responsible for providing services that would otherwise have been provided by the controlís own window. For example, if your control needs to query the keyboard focus, query the mouse capture, or obtain a device context, these operations are managed by the container. The COleControl windowless-operation member functions invoke these operations on the container.

When windowless activation is enabled, the container delegates input messages to the controlís IOleInPlaceObjectWindowless interface (an extension of IOleInPlaceObject for windowless support). COleControlís implementation of this interface will dispatch these messages through your controlís message map, after adjusting the mouse coordinates appropriately. You can process these messages like ordinary window messages, by adding the corresponding entries to the message map.

In a windowless control, you should always use the COleControl member functions instead of the corresponding CWnd member functions or their related Windows API functions.

OLE control objects can also create a window only when they become active, but the amount of work needed for the inactive-active transition goes up and the speed of the transition goes down. There are cases when this is a problem: as an example, consider a grid of text boxes. When cursoring up and down through the column, each control must be in-place activated and then deactivated. The speed of the inactive/active transition will directly affect the scrolling speed.

For more information on developing an OLE control framework, see the articles ActiveX Controls and Create a Program with the ActiveX ControlWizard in Visual C++ Programmer's Guide. For more information on adding functionality beyond the basic framework, see Building an ActiveX Control (the Circle tutorial) in Visual C++ Tutorials. For information on optimizing OLE controls, including windowless and flicker-free controls, see ActiveX Controls: Optimization in Visual C++ Programmer's Guide.

#include <afxctl.h>

Class MembersBase ClassHierarchy Chart

Samples    MFC Sample CIRC3 MFC Sample DRAWPIC MFC Sample TESTHELP

See Also   COlePropertyPage, CFontHolder, CPictureHolder