Re: @ operator ? Or maybe not
- From: erewhon@xxxxxxxxxx (J French)
- Date: Tue, 25 Oct 2005 11:26:16 +0000 (UTC)
On Mon, 24 Oct 2005 23:15:47 +0200, "Tom de Neef" <tdeneef@xxxxxxxx>
wrote:
>Suppose
>type
> myClass = class
> button : Tbutton;
> procedure method1(Sender: TObject);
> procedure method2(Sender: TObject);
> end;
>And somewhere I've assigned
>myClass.button.OnClick:=myClass.method1;
>How can I now verify if the OnClick is assigned to method1 or method2 ?
>I'd like to do
> button.enabled:=(@button.Onclick = @method1);
>But that isn't valid...
Rather than using @ use Addr it is a bit more typing but much more
explicit
- Addr( Button.OnClick ) is a storage location - Its address is
meaningless what is stored there is interesting
- Addr( Method1 ) is the address of the start of a procedure
- probably an Integer tucked away in the memory located by
Addr(Button.Onclick)
I have a nasty gut feeling that what you are trying to do is seriously
bad design - you are trying to let the Children identify their
Parents, which is a recipe for spaghetti
Right now I can't see a clean solution, but my gut feeling is that the
Button should be a descendant of TButton that has a property that can
be interrogated by the OnClick event handler
If ( Sender Is TtdnButton ) Then
( Sender As TtdnButton ).DoThisOrThatThing
I'm not sure, but I do know that what you are trying to do (or rather
the way you are trying to do it) is very, very wrong
- like it will bite you in the ***
.
- Follow-Ups:
- Re: @ operator ? Or maybe not
- From: Tom de Neef
- Re: @ operator ? Or maybe not
- References:
- @ operator ? Or maybe not
- From: Tom de Neef
- @ operator ? Or maybe not
- Prev by Date: 3D graphics with Delphi
- Next by Date: Re: Enum order in component view
- Previous by thread: Re: @ operator ? Or maybe not
- Next by thread: Re: @ operator ? Or maybe not
- Index(es):