Partager via


IVsComponentUser.AddComponent Method

Used by the environment to add components specified by the user in the Component Selector dialog to the specified project.

Namespace:  Microsoft.VisualStudio.Shell.Interop
Assembly:  Microsoft.VisualStudio.Shell.Interop (in Microsoft.VisualStudio.Shell.Interop.dll)

Syntax

'Déclaration
Function AddComponent ( _
    dwAddCompOperation As VSADDCOMPOPERATION, _
    cComponents As UInteger, _
    rgpcsdComponents As IntPtr(), _
    hwndPickerDlg As IntPtr, _
    <OutAttribute> pResult As VSADDCOMPRESULT() _
) As Integer
'Utilisation
Dim instance As IVsComponentUser
Dim dwAddCompOperation As VSADDCOMPOPERATION
Dim cComponents As UInteger
Dim rgpcsdComponents As IntPtr()
Dim hwndPickerDlg As IntPtr
Dim pResult As VSADDCOMPRESULT()
Dim returnValue As Integer

returnValue = instance.AddComponent(dwAddCompOperation, _
    cComponents, rgpcsdComponents, hwndPickerDlg, _
    pResult)
int AddComponent(
    VSADDCOMPOPERATION dwAddCompOperation,
    uint cComponents,
    IntPtr[] rgpcsdComponents,
    IntPtr hwndPickerDlg,
    VSADDCOMPRESULT[] pResult
)
int AddComponent(
    [InAttribute] VSADDCOMPOPERATION dwAddCompOperation, 
    [InAttribute] unsigned int cComponents, 
    [InAttribute] array<IntPtr>^ rgpcsdComponents, 
    [InAttribute] IntPtr hwndPickerDlg, 
    [OutAttribute] array<VSADDCOMPRESULT>^ pResult
)
function AddComponent(
    dwAddCompOperation : VSADDCOMPOPERATION, 
    cComponents : uint, 
    rgpcsdComponents : IntPtr[], 
    hwndPickerDlg : IntPtr, 
    pResult : VSADDCOMPRESULT[]
) : int

Parameters

  • rgpcsdComponents
    Type: array<System.IntPtr[]

    [in] Specifies rgpcsdComponents.

  • hwndPickerDlg
    Type: System.IntPtr

    [in] Specifies hwndPickerDlg.

Return Value

Type: System.Int32

If the method succeeds, it returns S_OK. If it fails, it returns an error code.

Remarks

COM Signature

From vsshell.idl:

HRESULT IVsComponentUser::AddComponent(
   [in] VSADDCOMPOPERATION dwAddCompOperation,
   [in] ULONG cComponents,
   [in, size_is(cComponents)] PVSCOMPONENTSELECTORDATA rgpcsdComponents[],
   [in] HWND hwndPickerDlg,
   [out, retval] VSADDCOMPRESULT *pResult
);

AddComponent is called back from ComponentSelectorDlg. The AddComponent method of the IVsComponentUser interface provided in the call to ComponentSelectorDlg will be invoked when the component selector dialog is dismissed.

The contents of pResult determine whether the dialog closes. If the component add succeeds or is cancelled by the user, the dialog is closed. If the component add operation fails, the dialog remains open.

In the AddComponent method, you loop on the cComponents count for rgpComponentData, add the data, and return the result from VSADDCOMPRESULT.

Permissions

See Also

Reference

IVsComponentUser Interface

IVsComponentUser Members

Microsoft.VisualStudio.Shell.Interop Namespace