RAD Studio
|
When you use a wizard to create a COM object, the wizard automatically generates a type library (unless you specify otherwise in the COM object wizard). The type library provides a way for host applications to find out what the object can do. It also lets you define your object's interface using the Type Library editor. The interfaces you define in the Type Library editor define what properties, methods, and events your object exposes to clients.
When you add a property to your object's interface using the Type Library Editor, it automatically adds a method to read the property's value and/or a method to set the property's value. The Type Library Editor, in turn, adds these methods to your implementation class, and in your implementation unit creates empty method implementations for you to complete.
When you add a method to your object's interface using the Type Library Editor, the Type Library Editor can, in turn, add the methods to your implementation class, and in your implementation unit create empty implementation for you to complete.
There are two types of events that a COM object can generate: traditional events and COM+ events.
unit ev; interface uses ComObj, AxCtrls, ActiveX, Project1_TLB; type TMyAutoObject = class (TAutoObject,IConnectionPointContainer, IMyAutoObject) private . . . public procedure Initialize; override; procedure Fire_MyEvent; { Add a method to fire the event}
procedure TMyAutoObject.Fire_MyEvent; var I: Integer; EventSinkList: TList; EventSink: IMyAutoObjectEvents; begin if FConnectionPoint <> nil then begin EventSinkList :=FConnectionPoint.SinkList; {get the list of client sinks } for I := 0 to EventSinkList.Count - 1 do begin EventSink := IUnknown(FEvents[I]) as IMyAutoObjectEvents; EventSink.MyEvent; end; end; end;
if EventOccurs then Fire_MyEvent; { Call method you created to fire events.}
if (EventOccurs) Fire_MyEvent; // Call method you created to fire events.
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|