Udostępnij za pośrednictwem


ISelectionContainer.GetObjects Method

Returns either the objects that are currently selected or the objects that are selectable.

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

Syntax

'Declaration
Function GetObjects ( _
    dwFlags As UInteger, _
    cObjects As UInteger, _
    <OutAttribute> apUnkObjects As Object() _
) As Integer
int GetObjects(
    uint dwFlags,
    uint cObjects,
    Object[] apUnkObjects
)
int GetObjects(
    [InAttribute] unsigned int dwFlags, 
    [InAttribute] unsigned int cObjects, 
    [OutAttribute] array<Object^>^ apUnkObjects
)
abstract GetObjects : 
        dwFlags:uint32 * 
        cObjects:uint32 * 
        apUnkObjects:Object[] byref -> int 
function GetObjects(
    dwFlags : uint, 
    cObjects : uint, 
    apUnkObjects : Object[]
) : int

Parameters

  • dwFlags
    Type: System.UInt32
    [in] Flag that specifies the type of objects to return. If set to GETOBJS_ALL, ISelectionContainer::GetObjects returns all selectable objects. If set to GETOBJS_SELECTED, only the currently selected objects are returned.
  • cObjects
    Type: System.UInt32
    [in] Specifies the requested number of objects to be returned.
  • apUnkObjects
    Type: array<System.Object[]
    [in] Pointer to an array of pointers to be selected or selectable objects that support the IDispatch interface.

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 designer.idl:

HRESULT ISelectionContainer::GetObjects(
   [in] DWORD dwFlags,
   [in] ULONG cObjects,
   [out, size_is(cObjects)] IUnknown ** apUnkObjects
);

To use GetObjects, the caller must first call CountObjects with the appropriate type (either selected or selectable) to determine the number of objects, then allocate an array with that size and pass it into GetObjects in the apUnkObjects parameter.

Because GetObjects is used to populate the Properties window, the objects returned must provide access to the properties to be displayed. In some cases, GetObjects returns a pointer to an extended object rather than to the object itself. An extended object has properties that do not directly belong to the selected object but can affect its appearance or behavior. For example, if the selected object is a button on a form, the form designer as the VSPackage object implementing GetObjects might include properties such as the X and Y position in the Properties window. In this case, GetObjects would return a pointer to the form rather than the selected button.

Because the returned objects support the IDispatch interface, the environment can obtain information directly from them. For example, a predefined dispatch identifier (DISPID) can be passed to IDispatch::Invoke to get an object's name. The predeclared DISPIDs are negative to ensure they do not conflict with user-defined identifiers.

The following table describes some of this information and how and from where it is obtained.

Information

Obtained From

Object name

IDispatch::Invoke using the DISPID_NAME dispatch identifier

Object index

IDispatch::Invoke using the DISPID_OBJECT dispatch identifier

Object type

IProvideClassInfo::QueryInterface

.NET Framework Security

See Also

Reference

ISelectionContainer Interface

Microsoft.VisualStudio.Shell.Interop Namespace