Activating ActiveX Controls

Note As of December 2011, this topic has been archived and is no longer actively maintained. For more information, see Archived Content. For information, recommendations, and guidance regarding the current version of Windows Internet Explorer, see Internet Explorer Developer Center.

Deprecated. Users cannot directly interact with Microsoft ActiveX controls loaded by the APPLET, EMBED, or OBJECT elements. Users can interact with such controls after activating their user interfaces. This topic describes how Internet Explorer handles ActiveX controls, shows how to load ActiveX controls so their interfaces are activated, and describes the impact of this behavior on accessibility tools and applications hosting the WebBrowser Control.

Note This topic contains information relevant to versions of Internet Explorer released or updated between April, 2006 and April, 2008. As of April, 2008, this behavior has been removed from Internet Explorer. For more information, please see Information for Developers about Internet Explorer.

Understanding Control Activation

Interactive controls are ActiveX controls that provide user interfaces. When a web page uses the APPLET, EMBED, or OBJECT elements to load an ActiveX control, the control's user interface is blocked until the user activates it. If a page uses these elements to load multiple controls, each interactive control must be individually activated.

When a control is inactive, the following effects occur.

Dynamic HTML (DHTML) events related to user interaction, such as onblur and onclick, are blocked. Appendix A lists the DHTML events that are blocked when a control is inactive.

The control does not respond to window messages generated by the keyboard or mouse, such as WM_CLICK and WM_KEYPRESS, and so on.

An overlay window, created on the control's OLE site, prevents keyboard and mouse messages from reaching the inactive control.

When an inactive control is created, Internet Explorer uses different techniques to prevent keyboard or mouse window messages from reaching the control. When the inactive control is a windowed control, such as the HTML Help Control, Internet Explorer uses the EnableWindow Function to disable the inactive control's window. When the user activates a windowed control, the same function activates the disabled window. When the inactive control is a windowless control, such as the Office Web Components, keyboard and mouse messages are filtered by the control's container.

When a control is inactive, it does not respond to user input; however, it does perform operations that do not involve interaction. If, for example, you open a web page that uses Microsoft Windows Media Player to play a music file, the music plays after the page loads. You cannot interact with Windows Media Player until the control's user interface is activated, as shown in the following figure.

Note While inactive controls do not respond to direct user interaction; they do respond to script commands.

To activate an interactive control, either click it or use the TAB key to set focus on it and then press the SPACEBAR or the ENTER key. Interactive controls loaded from external script files immediately respond to user interaction and do not need to be activated.

Some windowed controls use Windows API functions, such as GetKeyState and GetCursorPos, to determine the state of the keyboard and mouse and then respond to the function results. For these controls only, a prompt appears before the control is run in Internet Explorer. To run the control, the user needs to click the button in the message window before the page loads. After loading, the control will not require activation. At present, the following controls have this behavior, but the vendors are working on new controls that would not have this behavior.

Virtools (TM) Web Player from Virtools SA

Macromedia Shockwave Player (TM) from Adobe Systems Inc.

QuickTime (TM) from Apple Computer, Inc.

When loaded from external script files, these controls do not display a prompt.

The following screen shot shows the prompt dialog box.

Loading Interactive Controls Externally

To create Web pages that load interactive controls that respond immediately to user input, use Microsoft JScript to load controls from external script files. You cannot write script elements inline with the main HTML page to load your control externally. If the script is written inline programmatically, for example with the writeln function, the loaded control will behave as if it was loaded by the HTML document itself and will require activation. To ensure a control is interactive when it is loaded, use one of the following techniques to load your control from an external file.

Important When using createElement to add an Object or Embed element to a web page, use care to create the element, initialize its attributes, and add it to the page's DOM before creating the ActiveX control to be loaded by the new element. For more information, please see the createElement documentation.

Because the next example uses the writeln function to insert the script into the original HTML document, the resulting control requires activation. To load a control without requiring activation, use one of the previous examples.

Note To automatically activate ActiveX controls, Internet Explorer must be using versions of vbscript.dll and jscript.dll newer than September 30, 2003. Earlier versions of this DLL will require all controls to be activated, regardless of the mechanism used to load them from a web page.

Programmatically Determining Whether a Control is Inactive

You cannot use JScript functions or server-side scripts to determine whether or not a control is active. Application hosting the web browser control cannot determine whether or not a control is active.

Accessibility Impact

When accessibility tools encounter ActiveX controls, they can use the object's IAccessible interface to obtain information about the control. Inactive controls can be activated with the IAccessible::accDoDefaultAction method.

The following table describes the results when IAccessible methods are called on inactive controls.

Method

Description

IAccessible::accDoDefaultAction

Activates the control and will expose the ActiveX control or Java Applet within the MSAA tree.

IAccessible::accHitTest

Returns CHILDID_SELF

IAccessible::accLocation

Location of the underlying ActiveX control or Java Applet

IAccessible::accNavigate

Returns E_NOTIMPL

IAccessible::accSelect

Returns E_NOTIMPL

IAccessible::get_accChild

Returns S_FALSE

IAccessible::get_accChildCount

Returns 0 and S_OK

IAccessible::get_accDefaultAction

Returns "Select this control"

IAccessible::get_accDescription

Returns E_NOTIMPL

IAccessible::get_accFocus

Returns E_NOTIMPL

IAccessible::get_accHelp

Returns "This control is inactive. Select the control to activate and use it."

IAccessible::get_accHelpTopic

No Change - Returns E_NOTIMPL

IAccessible::get_accKeyboardShortcut

No Change - Delegates the object. If there is no object, the method returns E_NOTIMPL.

IAccessible::get_accName

Returns "Inactive Control"

IAccessible::get_accParent

No Change - Returns the closest accessible element in the parent chain.

IAccessible::get_accRole

Returns ROLE_SYSTEM_PUSHBUTTON

IAccessible::get_accSelection

Returns E_NOTIMPL

IAccessible::get_accState

Returns current state of the object. This state always includes STATE_SYSTEM_FOCUSABLE

WebBrowser Control Impact

Important The techniques in this section only apply to versions of the WebBrowser Control released or updated between April 2006 and April 2008; if your application uses one of these techniques to require control activation, your application may be affected by the April 2008 Internet Explorer Cumulative Update. After the update is applied to a user's copy of Internet Explorer, control activation will be required only for applications that use the DOCHOSTUIINFO structure to enable the behavior. The opt-in list and registry key are no longer supported after the April 2008 Internet Explorer Cumulative Update is applied.

Inactive control blocking only applies to the following applications.

Windows Explorer

Internet Explorer

MSN Explorer

AOL® Explorer

AOL® 8.0

AOL® 9.0

CompuServe 2000

AIM®

NetCaptor

Browse3D

Macromedia Dreamweaver

Macromedia Contribute

Netscape® 8 (when using Internet Explorer as the rendering engine)

To match the behavior of Internet Explorer in your application, add the DOCHOSTUIFLAG_ENABLE_ACTIVEX_INACTIVATE_MODE flag to the dwFlags parameter of your DOCHOSTUIINFO structure, as shown in the following example.