Re: Adding events to Run time created controls
From: Jim P (Jim_P_at_mad.scientist.com)
Date: 11/24/04
- Next message: Martin Harvey (Demon account): "Re: out of memory Delphi 5"
- Previous message: Jim P: "Re: out of memory Delphi 5"
- In reply to: Bruce Roberts: "Re: Adding events to Run time created controls"
- Next in thread: Martin Harvey (Demon account): "Re: Adding events to Run time created controls"
- Reply: Martin Harvey (Demon account): "Re: Adding events to Run time created controls"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 23 Nov 2004 15:35:49 -0800
Thanks Guys.
This is what I needed. I added this to some test code and it worked
just perfect.
I guess this old assembler, C and VB programmer has a few things to learn.
Don't try to get one property. Get the whole control and then you
have it all and more. Much more.
Got to change my way of thinking. and to think I was about to write a
routine to find the label by looping and checking the bounds of each
label to see which matchs with the mouse position.
Thanks again.
Jim P.
Bruce Roberts wrote:
> "Jim P" <Jim_P@mad.scientist.com> wrote in message
> news:jKqdncuSQOZOLz7cRVn-ug@comcast.com...
>
>
>>Got to be a simply solution to this. You just helped with one major
>>issue. Now to get back the tag or other information so that I know
>>which one of the labels in the array was clicked upon.
>
>
> The Sender parameter of a tNotifyEvent is conventionally the object that
> fired the event. IOW it will be the label that was clicked on. (This is one
> of the reasons why control arrays are rarely needed in Delphi.) So code your
> event something like
>
> procedure tSomeForm.LabelClick (Sender : tObject);
>
> var theLabel : tLabel;
>
> begin
> Assert (Sender is tLabel, 'Programmer error :) Only tLabel descendants can
> use this event.');
> theLabel := tLabel (Sender);
> // now you can use theLabel to reference the clicked label
> // e.g.
> theLabel.Font.Color := clRed;
> theLabel.Font.Style := [fsBold, fsItalic];
> . . .
> end;
>
> If you really need to index the array you could either search the array for
> Sender or put the appropriate array index in the Tag of each label.
>
>
- Next message: Martin Harvey (Demon account): "Re: out of memory Delphi 5"
- Previous message: Jim P: "Re: out of memory Delphi 5"
- In reply to: Bruce Roberts: "Re: Adding events to Run time created controls"
- Next in thread: Martin Harvey (Demon account): "Re: Adding events to Run time created controls"
- Reply: Martin Harvey (Demon account): "Re: Adding events to Run time created controls"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|