Re: Adding events to Run time created controls

From: Jim P (Jim_P_at_mad.scientist.com)
Date: 11/24/04


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.
>
>



Relevant Pages

  • Re: Adding events to Run time created controls
    ... >>which one of the labels in the array was clicked upon. ... IOW it will be the label that was clicked on. ... > Sender or put the appropriate array index in the Tag of each label. ... I do need the sender array index. ...
    (alt.comp.lang.borland-delphi)
  • Re: converting program variables to arrays
    ... to the program variables. ... variable to an array type such that I can store the value of the ... For starters it gets round the obvious problem that a simple array won't hold an int as and a string label as. ... martin@ | Martin Gregorie ...
    (comp.lang.java.programmer)
  • Re: Help sorting an array
    ... thank you very much for the replies. ... In the mean time I have managed to hack together a small function to do ... calendar) into an array, and using that array to create widgets in a ... The month names serve as the title of a label and out of the ...
    (comp.lang.ruby)
  • Re: discover array offsets within initializer?
    ... and have subsequent mentions of that label name ... be automatically replaced by the offset within the array ... have a set of enums corresponding to array indices. ... an X-macro version rather than multiple inclusion. ...
    (comp.lang.c)
  • RE: GetOpenFilename MultiSelect failure
    ... > Dim FName As Variant ... >> obtain a list of files as an array. ... For what it's worth, the test code follows. ...
    (microsoft.public.excel.programming)