BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Events in a COM Object

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi ActiveX Controls Development
View previous topic :: View next topic  
Author Message
Sergio Martins
Guest





PostPosted: Fri Aug 29, 2003 6:52 pm    Post subject: Events in a COM Object Reply with quote



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 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;


Sergio Martins Vieira
[email]martins (AT) rm (DOT) com.br[/email]
Brasil



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi ActiveX Controls Development All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.