Partager via


Désactiver l'activation lorsque option visible

Un contrôle possède deux états de base : actif et inactif. Traditionnellement, ces états ont été distingués par la possession ou non d'une fenêtre par le contrôle. Un contrôle actif avait une fenêtre ; un contrôle inactif n'en avait pas. Avec l'introduction de l'activation sans fenêtre, cette distinction n'est plus universelle, mais toujours applicable à de nombreux contrôles.

Compared with the rest of the initialization typically performed by an ActiveX control, the creation of a window is an extremely expensive operation. Ideally, a control would defer creating its window until absolutely necessary.

Many controls do not need to be active the entire time they are visible in a container. Often, a control can remain in the inactive state until the user performs an operation that requires it to become active (for example, clicking with the mouse or pressing the TAB key). To cause a control to remain inactive until the container needs to activate it, remove the OLEMISC_ACTIVATEWHENVISIBLE flag from the control's miscellaneous flags:

static const DWORD BASED_CODE _dwNVC_MFC_AxOptOleMisc =
   OLEMISC_SETCLIENTSITEFIRST |
   OLEMISC_INSIDEOUT |
   OLEMISC_CANTLINKINSIDE |
   OLEMISC_RECOMPOSEONRESIZE;

The OLEMISC_ACTIVATEWHENVISIBLE flag is automatically omitted if you turn off the Activate When Visible option in the Control Settings page of the MFC ActiveX Control Wizard when you create your control.

Voir aussi

Concepts

Contrôles ActiveX MFC : optimisation