Re: Why is onclick event firing here?
- From: "Maarten Wiltink" <maarten@xxxxxxxxxxxxxxxxxx>
- Date: Sun, 20 Aug 2006 21:15:55 +0200
"Brad Blanchard" <1122@xxxxxxxxxxxxxxxx> wrote in message
news:VA.00002f9b.020acc9b@xxxxxxxxxxxxx
There must be simple reason for this, but I can't see it. Why is the
onclick event firing here in the following code? How do I fix it? TIA.
function TMainForm.SetImgClicks(URLIndex : integer) : TNotifyEvent;
begin
Showmessage('img onclick');
end;
procedure TMainForm.SetImages;
var
num : integer;
begin
SetLength(imgarray,numItems);
for num := 0 to numItems -1 do
begin
imgarray[num]:= TImage.Create(self);
imgarray[num].Parent := MainForm;
imgarray[num].OnClick := SetImgClicks(num);
imgname := inttostr(num+1) +'.bmp';
end;
end;
You fix it by mentioning a method instead of using it. As Alan noted,
you are _calling_ SetImgClicks, not setting a property to it. The compiler
doesn't complain because the call returns the correct type to use at that
place: TNotifyEvent.
Turn on hints & warnings. The compiler will now (correctly) warn you
that SetImgClicks doesn't actually return any specific value.
Groetjes.
Maarten Wiltink
.
- Prev by Date: Re: Why is onclick event firing here?
- Next by Date: What compiler directives do i have to delete in the LAST compilation of my program ?
- Previous by thread: Re: Why is onclick event firing here?
- Next by thread: What compiler directives do i have to delete in the LAST compilation of my program ?
- Index(es):
Relevant Pages
|