Export (0) Print
Expand All

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.

This topic contains the following sections.

For an introduction to the user experience, please see Internet Explorer 6: ActiveX Update.

For additional information regarding the platforms affected by this update, please see Internet Explorer ActiveX Update.

Affected Versions

The information in this article is now deprecated; it originally applied to the following versions of Internet Explorer.

  • Microsoft Internet Explorer 6 in Windows XP Service Pack 2 (SP2)
  • Internet Explorer 6 in Windows Server 2003 Service Pack 1 (SP1)
  • Internet Explorer 6 in Windows Server 2003 Release 2 (R2)
  • Internet Explorer 6 in Windows Server 2003 Service Pack 2 (SP2)
  • Windows Internet Explorer 7 in Windows XP SP2
  • Internet Explorer 7 in Windows Server 2003 SP1
  • Internet Explorer 7 in Windows Server 2003 SP2
  • Internet Explorer 7 on Windows Vista

When the April 2008 Internet Explorer Cumulative Update is applied to any of these versions, the behavior described in this article is removed from Internet Explorer. In addition, the update also affects applications hosting the WebBrowser Control.

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.

Button for activating Windows Media Player

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.

Prompt in Internet Explorer

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.

The following example uses document.write to load a control dynamically.


<!-- HTML File -->
<html>
  <body leftmargin=0 topmargin=0 scroll=no>
    <script src="docwrite.js"></script>
  </body>
</html>


// docwrite.js
document.write('<object classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6">');
document.write('<param name="URL" value="example.wmv">');
document.write('<param name="autoStart" value="-1"></object>');


External script files can also modify an element's outerHTML property to achieve the same effect, as shown in the following example.


<!-- HTML File -->
<html>
  <body> 
    <div id="embedControlLocation">
      <script src="embedControlOuterHTML.js"></script>
    </div>
  </body>
</html>


// outerhtml.js
embedControlLocation.outerHTML = '<embed src="examplecontrol">';

The next example uses document.createElement to load an ActiveX control using the OBJECT element.

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.


<!-- HTML File -->
<html>
  <body> 
    <div id="DivID">
      <script src="createElementExplicit.js"></script>
    </div>  
  </body>
</html>


// createElementExplicit.js
var myObject = document.createElement('object');
DivID.appendChild(myObject);
myObject.width = "200";
myObject.height = "100";
myObject.classid= "clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6"; 
myObject.URL = "example.wmv";
myObject.uiMode = "none" ;

The next example uses innerHTML and a JScript function to load an ActiveX control while specifying parameter values.


<!-- HTML File -->
<html>
 <head>
   <script src="external_script.js" language="JScript"></script>
 </head>
 
 <body>
   <div id="EXAMPLE_DIV_ID">
      This text will be replaced by the control
   </div>
   <script language="JScript">
     CreateControl( "EXAMPLE_DIV_ID",
                    "clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6",
                    "EXAMPLE_OBJECT_ID", "600", "400", "example.wmv",
                    "-1")
   </script>
 </body>
</html>


// external_script.js
function CreateControl(DivID, CLSID, ObjectID,
                       WIDTH, HEIGHT, URL, AUTOSTART)
{
  var d = document.getElementById(DivID);
  d.innerHTML = 
    '<object classid=' + CLSID + ' id=' + ObjectID + 
    ' width=' + WIDTH + ' height=' + HEIGHT +'>
    <param name="URL" value=' + URL + '>
    <param name="autoStart" value=' + AUTOSTART + '/>';
}

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.


<!-- HTML File -->
<html>
  <body> 
    <div id="embedControlLocation">
      <script id="elementid" src="embedControl.js"></script> 
    </div>
  </body>
</html>


// embedControl.js
document.writeln('<script>');
document.write('document.writeln(\'');
document.write( '<object classid = 
                "clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" 
                width="100" height="100" />');
document.write('\');');
document.writeln('</script>');


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.

Controls can determine activation state via the DISPID_AMBIENT_UIDEAD ambient property by calling through IDispatch::Invoke. Controls that implement the IOleControl interface are notified when this property changes through IOleControl::OnAmbientPropertyChange.

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.

MethodDescription
IAccessible::accDoDefaultActionActivates the control and will expose the ActiveX control or Java Applet within the MSAA tree.
IAccessible::accHitTestReturns CHILDID_SELF
IAccessible::accLocationLocation of the underlying ActiveX control or Java Applet
IAccessible::accNavigateReturns E_NOTIMPL
IAccessible::accSelectReturns E_NOTIMPL
IAccessible::get_accChildReturns S_FALSE
IAccessible::get_accChildCountReturns 0 and S_OK
IAccessible::get_accDefaultActionReturns "Select this control"
IAccessible::get_accDescriptionReturns E_NOTIMPL
IAccessible::get_accFocusReturns E_NOTIMPL
IAccessible::get_accHelpReturns "This control is inactive. Select the control to activate and use it."
IAccessible::get_accHelpTopicNo Change - Returns E_NOTIMPL
IAccessible::get_accKeyboardShortcutNo Change - Delegates the object. If there is no object, the method returns E_NOTIMPL.
IAccessible::get_accNameReturns "Inactive Control"
IAccessible::get_accParentNo Change - Returns the closest accessible element in the parent chain.
IAccessible::get_accRoleReturns ROLE_SYSTEM_PUSHBUTTON
IAccessible::get_accSelectionReturns E_NOTIMPL
IAccessible::get_accStateReturns current state of the object. This state always includes STATE_SYSTEM_FOCUSABLE
IAccessible::get_accValueReturns E_NOTIMPL
IAccessible::put_accNameReturns E_NOTIMPL
IAccessible::put_accValueReturns E_NOTIMPL

 

For information on activated controls, or controls that do not require activation please see the Microsoft Active Accessibility SDK.

Note  Accessibility tools should refresh after triggering the default action in order to properly display the ActiveX control's data and the data of its children, if any.

WebBrowser Control Impact

By default, custom applications hosting the WebBrowser Control do not block interactive ActiveX controls loaded by the APPLET, EMBED, or OBJECT elements.

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.


HRESULT GetHostInfo(DOCHOSTUIINFO *pInfo)
{
   ...

    pInfo->cbSize = sizeof(DOCHOSTUIINFO);
    pInfo->dwFlags = { Other DOCHOSTUIFLAGs } | 
      DOCHOSTUIFLAG_ENABLE_ACTIVEX_INACTIVATE_MODE;  
   ...

    return S_OK;
}

You can also enable interactive control blocking by adding your application's process name to the following registry key.

HKEY_LOCAL_MACHINE (or HKEY_CURRENT_USER)
   SOFTWARE
      Microsoft
         Internet Explorer
            Main
               FeatureControl
                  FEATURE_ENABLE_ACTIVEX_INACTIVATE_MODE
                     process_name.exe = (DWORD) 0x00000001

Note  Because users can modify the registry, the DOCHOSTUIINFO flag is the preferred way to enable interactive control blocking.

Applications can register to incorporate ActiveX control activation by default. For more information, please engage your Technical Account Manager or contact Microsoft Product Support.

Appendix A: DHTML Events Blocked by Inactive Controls

The following table lists the DTHML events that are blocked when ActiveX controls are inactive.

onactivate ondragleave onmouseout
onbeforeactivate ondragover onmouseover
onbeforecopy ondragstart onmouseup
onbeforecut ondrop onmousewheel
onbeforedeactivate onfocus onmove
onbeforepaste onfocusin onmoveend
onblur onfocusout onmovestart
onclick onhelp onpage
oncontextmenu onkeydown onpaste
oncontrolselect onkeypress onresize
oncopy onkeyup onresizeend
oncut onlosecapture onresizestart
ondblclick onmousedown onscroll
ondeactivate onmouseenter onselectstart
ondragend onmouseleave  
ondragenter onmousemove  

 

 

 

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft