Есть такой кусок кода в программе
Код:
type BitButtonClass = class
class procedure BitClick(Sender : TObject);
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var Forma : TForm;
BitButton1 : TBitBtn;
BitButton2 : TBitBtn;
BitButton3 : TBitBtn;
A : TDBGrid;
begin
//
Forma := TForm.Create(Self);
With Forma do
begin
Left := 100;
Top := 100;
Height := 300; // Высота формы
Width := 300; // Ширина формы
BorderStyle := bsDialog;
end;
BitButton1 := TBitBtn.Create(Forma);
With BitButton1 do
begin
Parent := Forma;
Left := 20;
Top := 235;
Height := 25; // Высота
Width := 75; // Ширина
Caption :='Добавить';
Visible := true;
OnClick := BitButtonClass.BitClick;
end;
class procedure BitButtonClass.BitClick(Sender: TObject);
begin
if TBitBtn(Sender).Name = 'BitButton1' then
begin
ShowMessage('1111');
end;
if (Sender as TBitBtn).Name = 'BitButton2' then
begin
ShowMessage('2');
end;
if (Sender as TBitBtn).Name = 'BitButton3' then
begin
ShowMessage('3');
end;
ShowMessage('4');
end;
При этом параметр sender в обработчик события не передается - он пустой. Как следствие непонятно кто создал событие. Как можно определить, кто вызвал событие, в чем проблема?