Поделиться через


CAxWindow::CreateControl

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

HRESULT CreateControl(
   LPCOLESTR lpszName,
   IStream* pStream = NULL,
   IUnknown** ppUnkContainer = NULL 
);
HRESULT CreateControl(
   DWORD dwResID,
   IStream* pStream = NULL,
   IUnknown** ppUnkContainer = NULL 
);

Параметры

  • 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>"

      ПримечаниеПримечание.

      "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.

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

Возвращаемое значение

A standard HRESULT value.

Заметки

If the second version of this method is used, an HTML control is created and bound to the resource identified by dwResID.

This method gives you the same result as calling:

AtlAxCreateControlEx(lpszName, hWnd, pStream, NULL, NULL, GUID_NULL, NULL);

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

Пример

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

Требования

Header: atlwin.h

См. также

Основные понятия

CAxWindow Class

CAxWindow Members

AtlAxCreateControl