Partager via


CAxWindow::CreateControlEx

Creates an ActiveX control, initializes it, and hosts it in the specified window.

HRESULT CreateControlEx(
   LPCOLESTR lpszName,
   IStream* pStream = NULL,
   IUnknown** ppUnkContainer = NULL,
   IUnknown** ppUnkControl = NULL,
   REFIID iidSink = IID_NULL,
   IUnknown* punkSink = NULL 
);
HRESULT CreateControlEx(
   DWORD dwResID,
   IStream* pStream = NULL,
   IUnknown** ppUnkContainer = NULL,
   IUnknown** ppUnkControl = NULL,
   REFIID iidSink = IID_NULL,
   IUnknown* punkSink = NULL 
);

Parameters

  • lpszName
    A pointer to a string to create the control. Must be formatted in one of the following ways:

    • A ProgID such as "MSCAL.Calendar.7"

    • A CLSID such as "{8E27C92B-1264-101C-8A2F-040224009C02}"

    • A URL such as "https://www.microsoft.com"

    • A reference to an Active document such as "file://\\Documents\MyDoc.doc"

    • A fragment of HTML such as "MSHTML:<HTML><BODY>This is a line of text</BODY></HTML>"

      Notes

      "MSHTML:" must precede the HTML fragment so that it is designated as being an MSHTML stream. Only the ProgID and CLSID are supported in Windows Mobile platforms. Windows CE embedded platforms, other than Windows Mobile with support for CE IE support all types including ProgID, CLSID, URL, reference to active document, and fragment of HTML.

  • pStream
    [in] A pointer to a stream that is used to initialize the properties of the control. Can be NULL.

  • ppUnkContainer
    [out] The address of a pointer that will receive the IUnknown of the container. Can be NULL.

  • ppUnkControl
    [out] The address of a pointer that will receive the IUnknown of the control. Can be NULL.

  • iidSink
    [in] The interface identifier of an outgoing interface on the contained object. Can be IID_NULL.

  • punkSink
    [in] A pointer to the IUnknown interface of the sink object to be connected to the connection point on the contained object specified by iidSink.

  • dwResID
    [in] The resource ID of an HTML resource. The WebBrowser control will be created and loaded with the specified resource.

Return Value

A standard HRESULT value.

Remarks

This method is similar to CAxWindow::CreateControl, but unlike that method, CreateControlEx also allows you to receive an interface pointer to the newly created control and set up an event sink to receive events fired by the control.

See CAxWindow2T::CreateControlLicEx to create, initialize, and host a licensed ActiveX control.

Example

See Hosting ActiveX Controls Using ATL AXHost for a sample that uses CreateControlEx.

Requirements

Header: atlwin.h

See Also

Reference

CAxWindow Class

AtlAxCreateControlEx

Other Resources

CAxWindow Members