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 

[D6Ent] How to get object address of method pointer

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi (General)
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Wed Nov 29, 2006 2:17 am    Post subject: [D6Ent] How to get object address of method pointer Reply with quote



Hi all,

I have problem with geting the address of object.
I want to do something like this:

function ExtractSubject(rn: TMyNotification): TComponent;
begin
if @rn = Nil then
Result:=Nil
else
Result:=TComponent(@rn); // hire is the problem
end;

I need the reference to the object(class) the method belongs to, not
the address of the procedure itself.

TMyNotification is:
TMyNotification = procedure (Sender: TObject; rr: TMyReason) of
object;

Thanks for any answer.
G.M.
Back to top
Guest






PostPosted: Wed Nov 29, 2006 4:35 am    Post subject: Re: [D6Ent] How to get object address of method pointer Reply with quote



Hire is the solution:

function ExtractSubject(rn: TMyNotification): TComponent;
var
Address: Pointer;
x: array[0..1] of Integer;
begin
if @rn = Nil then
Result:=Nil
else
begin
Address:=@@rn;
CopyMemory(@x, Address, SizeOf(Integer)*2);
Result:=TComponent(x[1]);
end;
end;

Bye, bye.
G.M.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi (General) 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.