ISelectionContainer.GetObjects(UInt32, UInt32, Object[]) Method

Definition

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

public:
 int GetObjects(System::UInt32 dwFlags, System::UInt32 cObjects, cli::array <System::Object ^> ^ apUnkObjects);
public:
 int GetObjects(unsigned int dwFlags, unsigned int cObjects, Platform::Array <Platform::Object ^> ^ apUnkObjects);
int GetObjects(unsigned int dwFlags, unsigned int cObjects, std::Array <winrt::Windows::Foundation::IInspectable const &> const & apUnkObjects);
public int GetObjects (uint dwFlags, uint cObjects, object[] apUnkObjects);
abstract member GetObjects : uint32 * uint32 * obj[] -> int
Public Function GetObjects (dwFlags As UInteger, cObjects As UInteger, apUnkObjects As Object()) As Integer

Parameters

dwFlags
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
UInt32

[in] Specifies the requested number of objects to be returned.

apUnkObjects
Object[]

[in] Pointer to an array of pointers to be selected or selectable objects that support the IDispatch interface.

Returns

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

Applies to