You are right...but
i still have exception. I think it steel is wrong the Obj Pointer.
About the address of the method call, i can see (from CPU windows debug)
it's right.

any tips?

Thank you,
Mauro Russo.

----- Original Message -----
From: "Rob Kennedy" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Wednesday, May 17, 2006 12:23 AM
Subject: Re: [delphi-en] final question on TMethod and similar


> Mauro Russo wrote:
> > type TP = procedure(a : integer) of object;
> > type P_TP = ^TP;
> >
> > procedure TForm1.Button1Click(Sender: TObject);
> > var
> >    ParamMethod : TArrayOfPointers;
> >    m : procedure(a : integer) of object;
>
> Since you have declared a type name for that, go ahead and use it:
>
> var
>   m: TP;
>
> >    a : integer;
> >    m1 : Pointer;
> > begin
> >    App(0);
> >    m := App;
> >    m1 := @m;
> >    a := 1027;
> >
> >    m(0);
> >
> >    P_TP(@m1)^(3);
>
> M1 is a Pointer. It currently points to something of type TP, which means
> that its real type should be declared as P_TP. (When you declare things
> with typed pointers instead of just Pointer, you can remove a lot of
> type-casts, and then the compiler can help you find errors.)
>
> When you say "@m1", you get a pointer to that variable, so you get a value
> of type P_P_TP. That's not the same as a P_TP, so it's not valid to
> type-cast it like that.
>
> M1 is already holding a P_TP, so type-cast it directly:
>
> P_TP(m1)^(3);
>
> > end;
> >
> > procedure TForm1.App(a : integer);
> > var pSelf : Pointer;
> > begin
> >    pSelf := @Self;
> >
> >    if (Self.Height < 543) or (pSelf = Pointer(52)) then
>
> What's with 52? I'm quite certain pSelf's value will never be 52 in a
> valid program.
>
> >       Self.Height := Self.Height div 2;
> > end;
> >
> >
> > generates an exception in  the call "P_TP(@m1)^(3);"
>
> I'm not really sure what you're trying to do, but it's almost certainly
> not the right way to do it. Please explain what task you're trying to
> accomplish instead of just showing us glimpses of your attempted solution.
>
> --
> Rob
>
>
>
>
>
> -----------------------------------------------------
> Home page: http://groups.yahoo.com/group/delphi-en/
> To unsubscribe: [EMAIL PROTECTED]
> Yahoo! Groups Links
>
>
>
>
>
>
>
>



-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED]




YAHOO! GROUPS LINKS




Reply via email to