Re: Adding events to Run time created controls
From: Bruce Roberts (ber_at_bounceitattcanada.xnet)
Date: 11/23/04
- Next message: Bruce Roberts: "Re: out of memory Delphi 5"
- Previous message: Jim P: "Re: out of memory Delphi 5"
- In reply to: Jim P: "Re: Adding events to Run time created controls"
- Next in thread: Jim P: "Re: Adding events to Run time created controls"
- Reply: Jim P: "Re: Adding events to Run time created controls"
- Reply: Jim P: "Re: Adding events to Run time created controls"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 23 Nov 2004 17:31:12 -0500
"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: Bruce Roberts: "Re: out of memory Delphi 5"
- Previous message: Jim P: "Re: out of memory Delphi 5"
- In reply to: Jim P: "Re: Adding events to Run time created controls"
- Next in thread: Jim P: "Re: Adding events to Run time created controls"
- Reply: Jim P: "Re: Adding events to Run time created controls"
- Reply: Jim P: "Re: Adding events to Run time created controls"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|