Share via


MFC ActiveX Controls: Optimization

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at MFC ActiveX Controls: Optimization.

This article explains techniques you can use to optimize your ActiveX controls for better performance.

The topics Turning Off the Activate When Visible Option and Providing Mouse Interaction While Inactive discuss controls that don't create a window until activated. The topic Providing Windowless Activation discusses controls that never create a window, even when they are activated.

Windows have two major drawbacks for OLE objects: they prevent objects from being transparent or nonrectangular when active, and they add a large overhead to the instantiation and display of controls. Typically, creating a window takes 60 percent of a control's creation time. With a single shared window (usually the container's) and some dispatching code, a control receives the same window services, generally without a loss of performance. Having a window is mostly unnecessary overhead for the object.

Some optimizations do not necessarily improve performance when your control is used in certain containers. For example, containers released prior to 1996 did not support windowless activation, so implementing this feature will not provide a benefit in older containers. However, nearly every container supports persistence, so optimizing your control's persistence code will likely improve its performance in any container. If your control is specifically intended to be used with one particular type of container, you may want to research which of these optimizations is supported by that container. In general, however, you should try to implement as many of these techniques as are applicable to your particular control to ensure your control performs as well as it possibly can in a wide array of containers.

You can implement many of these optimizations through the MFC ActiveX Control Wizard, on the Control Settings page.

MFC ActiveX Control Wizard OLE Optimization Options

Control setting in the MFC ActiveX Control Wizard Action More information
Activate when visible check box Clear Turning Off the Activate When Visible Option
Windowless activation check box Select Providing Windowless Activation
Unclipped device context check box Select Using an Unclipped Device Context
Flicker-free activation check box Select Providing Flicker-Free Activation
Mouse pointer notifications when inactive check box Select Providing Mouse Interaction While Inactive
Optimized drawing code check box Select Optimizing Control Drawing

For detailed information about the member functions that implement these optimizations, see COleControl. The member functions are listed by use, such as Windowless Operations and Inactive Pointer Handling Functions.

For more information, see:

See Also

MFC ActiveX Controls