我在这些图像中创建和加载图片的过程,但是如何创建 OnClick 过程并确定我点击的是哪个?
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, jpeg, ExtCtrls, Math, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
procedure FormCreate(Sender: TObject);
private
procedure ImageClick(Sender: TObject);
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Box: array [1..8,1..8] of TImage;
size: integer;
implementation
{$R *.dfm}
procedure imagecreation;
var i,j: integer;
begin
size:=60;
for i:=1 to 8 do
begin
for j:=1 to 8 do
begin
box[i,j]:=Timage.Create(Form1);
box[i,j].AutoSize:=false;
box[i,j].Proportional:=true;
box[i,j].Width:=size;
box[i,j].Height:=size;
box[i,j].Top:=(i+1)*size;
box[i,j].Left:=(j+1)*size;
box[i,j].Parent:=Form1;
box[i,j].OnClick:=ImageClick;
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
imagecreation;
end;
procedure TForm1.ImageClick(Sender: TObject);
var
ClickedImage: TImage;
begin
ClickedImage := Sender as TImage;
end;
end.
此时它调用“ImageClick”和未声明的标识符。这些是如何声明的?