Board index » delphi » Events in a COMObject
Sergio Martins Vieira
![]() Delphi Developer |
Events in a COMObject2003-09-10 12:52:47 AM delphi251 Dears I need to build a structure like this description. I want build an COMObject and to published one (or more) events (OnSomething). Inside of object's procedures (AnyMethod) I intend to perfom a test and call this event (like "if event <>NIL then call event). In a Client (a .exe Delphi or VB(Visual Basic) or Java or C++ or C# or ...) I will instanciate this object, to build a function (MyFunction with a ShowMessage for example), assign this function (MyFunction) to object event to, when I to invoke the method (AnyMethod) it will execute and call the function in the client (the function with the ShowMessage). How to do this ? Could someone send me an example or link or ... ? thanks ... Ex. Like this COMObject (Server) type TEvent = class(xxx) private public private protected { Protected declarations } procedure AnyMethod; safecall; procedure OnSomethig; end; ... procedure TEvento.AnyMethod; begin for i := 0 to 1000 do if ((i mod 100) = 0) then if (Assigned(OnSomethig) <>NIL) OnSomethig; end; ---------------------------------------------------------------------------- ---------------- EXE Client (Delphi, VB, Java, C++, C#, etc) ... function MyFunction() begin ShowMessage('XXXXXXXXXXXXXXXXXXXXXXXXXX'); end procedure ClickDeUmbotão() begin obj := Instanciate the COMObject; obj.OnSomethig:= MyFunction; //Assign my function to event on COMObject obj.AnyMethod(); end; * XXXX@XXXXX.COM |