(sender:Tobject) - I don't get it.

I thought I understood sender. Please explain the following:

(D5):

A form with a radiogroup with 2 items.
A button on the form which sets the radiogroup to the first item.

I am trying to have the program work out where the change to the
radiogroup came from so I'm checking the value of "sender" on the
radiogroup click.

The actual code is:

procedure TForm1.Button1Click(Sender: TObject);
begin
     radiogroup1.itemindex:=0;
end;

procedure TForm1.RadioGroup1Click(Sender: TObject);
begin
     if sender=activecontrol then messagebeep(0);
end;

-------------

I am expecting to receive a beep only when I click on radiogroup and NOT
when I click on button.

I press the radiogroup items: no beeps.
I press the button: no beep.
------

I Changed to this:

procedure TForm1.RadioGroup1Click(Sender: TObject);
begin
     if sender=radiogroup1 then messagebeep(0);
end;

It beeps every time even if I press the button.

What am I missing?

Bernard Hill
Braeburn Software
Author of Music Publisher system
Music Software written by musicians for musicians
http://www.braeburn.co.uk
Selkirk, Scotland
01750 21854
+44 1750 21854