There is a code:
var
myobject: OleVariant;
begin
myobject := CreateOleObject('SomeNamespace.SomeClass');
end;
This COM object has events (for example OnClick). How should I connect to these events without importing TLB?
You are working with COM late-binding, so do you need write a lot of code to handle events. this task is not difficult if you know COM, basically do you need follow these steps.
TInterfacedObject
that implements IDispatch
Invoke()
function of your new class IConnectionpointContainer
) and desired connection point. IConnectionPointContainer.FindConnectionPoint
IConnectionPoint.Advise()
using your implementation of the IDispatch
you can found examples of this implementation on these links
try out these links for more info about COM, late-binding and events
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.