IDesignerToolboxSite::AddControl

Requests that the host add an ActiveX control to the toolbox.

HRESULT AddControl (
   REFCLSID rclsid
);

Parameter

rclsid

[in] Class ID of the control to add.

Return Values

The return value obtained from HRESULT is one of the following:

Return Value Meaning
S_OK Success.
E_INVALIDARG The argument is invalid.

Comments

A designer that hosts ActiveX controls can call AddControl to inform its site about ActiveX controls currently on the designer or ActiveX controls that are useful to the designer. The host needs to know which controls are present so it can display the control's bitmap in the toolbox and add a reference to the control. Adding a reference in this manner is the equivalent of using the Components dialog on the Project menu in Visual Basic.

The designer calls this method in the following situations:

Controls added with this method appear on the General toolbox tab in Visual Basic 6.0, not on the designer's own tab (if it has one).

Example

The following code fragment queries for the IDesignerToolboxSite interface in the SDesignerToolboxSite service, then calls AddControl to add the control with class ID rclsid.

hr = pServiceProvider->QueryService(SID_DesignerToolboxSite,
   IID_IDesignerToolboxSite, (void **)&piToolboxSite);
if (FAILED(hr)) return;
hr = piToolboxSite->AddControl(rclsid);
if (FAILED(hr)) return;