defaultvtable
Enables an object to have two different source interfaces.
Allowed on
A member of a coclass.
Flags
IMPLTYPEFLAG_FDEFAULTVTABLE. (If this flag is set, then IMPLTYPEFLAG_FSOURCE is also set.)
Remarks
The default interface is an interface or dispinterface that is the default source interface. If the interface is a:
dual interface, event sinks receive events through IDispatch.
VTBL interface, event sinks receive events through VTBL.
dispinterface, event sinks receive events through IDispatch.
defaultvtable, a default VTBL interface, which cannot be a dispinterface — it must be a dual, VTBL, or interface. If the interface is a dual interface, then event sinks receive events through the VTBL.
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.
For normal (non-source) interfaces, an object can support a single interface that satisfies consumers who want to use IDispatchaccess 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 |
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;
}
Related topics