DefaultColleem 屬性

[defaultcollelem] 屬性將屬性標記為預設集合元素的存取函式。

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

參數

屬性-屬性-列表

其他適用於該物業的屬性。

回傳型

指定函式的回傳類型。

物業名稱

屬性的名稱。

prop-param-list(題值列表)

一列與該屬性相關的零個或多個參數。

備註

[defaultcollelem]屬性用於Visual Basic ®程式碼優化。 如果介面或 dispinterface 的成員被標記為存取函式,則呼叫會直接傳送到該成員。

[ defaultcollelem] 的使用必須對某個物業保持一致。 例如,如果你在 Get 屬性上使用該屬性,該屬性也必須存在於 Let 屬性上。

類型旗表示法

FUNCFLAG_FDEFAULTCOLLELEM或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

另請參閱

ODL 檔案語法

ODL 檔案範例

使用 MIDL 產生型別函式庫