Export (0) Print
Expand All
COM
id
in
int
odl
out
ptr
ref
Expand Minimize
This topic has not yet been rated - Rate this topic

defaultcollelem attribute

The [defaultcollelem] attribute flags a property as an accessor function for an element of the default collection.


[property-attribute-list, defaultcollelem] return-type property-name(prop-param-list)

Parameters

property-attribute-list

Other attributes that apply to the property.

return-type

Specifies the return type of the function.

property-name

The name of the property.

prop-param-list

A list of zero or more parameters associated with the property.

Remarks

The [defaultcollelem] attribute is used for Visual Basic® code optimization. If a member of an interface or dispinterface is flagged as an accessor function, then the call will go directly to that member.

Use of [defaultcollelem] must be consistent for a property. For example, if you use the attribute on a Get property, it must also be present on a Let property.

Typeflags Representation

The presence of FUNCFLAG_FDEFAULTCOLLELEM or VARFLAG_FDEFAULTCOLLELEM.

Examples

//A form has a button on it named Button1. 
//To enable use of the property syntax and efficient use of the !
//syntax, the form describes itself in type info this way.
[
    dual,
    uuid(12345678-1234-1234-1234-123456789ABC),
    helpstring("This is IForm"),
    restricted
]
interface IForm1: IForm
{
    [propget, defaultcollelem] HRESULT Button1(
        [out, retval] Button *Value);
}

//User code may access the button using property syntax or ! syntax.

Sub Test()
Dim f as Form1
Dim b1 As Button
Dim b2 As Button

Set f = Form1

Set b1 = f.Button1        ' Property syntax
Set b = f!Button1        ' ! syntax
End Sub

See also

ODL File Syntax
ODL File Example
Generating a Type Library With MIDL

 

 

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.