Platform SDK: Automation

defaultvtable

Description

Enables an object to have two different source interfaces.

Comments

The default interface is an interface or dispinterface that is the default source interface. If the interface is a:

An object can have both a default source and a default VTBL source interface with the same interface identifier (IID or GUID). In this case, a sink should advise using IID_IDISPATCH to receive dispatch events, and use the specific interface identifier to receive VTBL events.

Allowed on

A member of a coclass.

Comments

For normal (non-source) interfaces, an object can support a single interface that satisfies consumers who want to use IDispatch access as well as VTBL access (a dual interface). Because of the way source interfaces work, it is not possible to use dual interface for source interfaces. The object with the source interface is in control of whether calls are made through IDispatch or through the VTBL. The sink does not provide any information about how it wants to receive the events. The only action that object-sourcing events can take would be to use the least common denominator, the IDispatch interface. This effectively reduces a dual interface to a dispatch interface with regard to sourcing events.

Interface Flag it translates into
default IMPLTYPEFLAG_FDEFAULT
default, source IMPLTYPEFLAG_FDEFAULT

IMPLTYPEFLAG_FSOURCE

defaultvtable, source IMPLTYPEFLAG_FDEFAULT

IMPLTYPEFLAG_FDEFAULTVTABLE

IMPLTYPEFLAG_FSOURCE


Flags

IMPLTYPEFLAG_FDEFAULTVTABLE. (If this flag is set, then IMPLTYPEFLAG_FSOURCE is also set.)

Example

[    odl, 
    dual,
    uuid(1e196b20-1f3c-1069-996b-00dd010ef676),
    restricted
]
interface IForm: IDispatch
{
    [propget]
    HRESULT Backcolor([out, retval] long *Value);

    [propput]
    HRESULT Backcolor([in] long Value);


    [propget]
    HRESULT Name([out, retval] BSTR *Value);

    [propput]
    HRESULT Name([in] BSTR Value);
}

[    odl, 
    dual,
    uuid(1e196b20-1f3c-1069-996b-00dd010ef767),
    restricted
]
interface IFormEvents: IDispatch
{
    HRESULT Click();
    HRESULT Resize();
}

[uuid(1e196b20-1f3c-1069-996b-00dd010fe676)]
coclass Form
{
    [default] interface IForm;
    [default, source] interface IFormEvents;
    [defaultvtable, source] interface IFormEvents;
}