我的代码有问题但找不到解决方案,已经以各种方式修改但没有成功。
代码:
private
{ Private declarations }
procedure getImgInfo(Sender: TObject; A, B: String);
和:
procedure TfMain.Button1Click(Sender: TObject);
var
i, Idx, Left, Top, Count : integer;
Graph : TGraphic;
Img : TImage;
EdPath, EdFileName : TEdit;
begin
openImg.Execute;
Left := 5;
Top := 5;
Count := 0;
Idx := 0;
for i:=0 to openImg.Files.Count-1 do
begin
try
begin
Graph := TPngImage.Create;
Graph.LoadFromFile(openImg.Files[i]);
EdPath := TEdit.Create(pImgs);
EdPath.Left := Left + 101;
EdPath.Visible := False;
EdPath.Text := ExtractFilePath(openImg.Files[i]);
EdFileName := TEdit.Create(pImgs);
EdFileName.Left := Left + 101;
EdFileName.Visible := False;
EdFileName.Text := ExtractFileName(openImg.Files[i]);
Img := TImage.Create(pImgs);
Img.Parent := pImgs;
Idx := Idx + 1;
Img.Name := 'Img_'+IntToStr(Idx);
Img.Width := 100;
Img.Height := 100;
Img.Left := Left;
Img.Proportional := True;
Left := Left + 101;
Img.Top := Top;
Img.Picture.Assign(Graph);
Img.BringToFront;
Count := Count + 1;
Img.OnClick := getImgInfo(Img, edPath.Text, edFileName.Text); //Error line
if Count = 2 then
begin
Left := 5;
Top := Top + 101;
Count := 0;
end;
end;
except on E : Exception do
ShowMessage('Error: :' + E.Message);
end;
end;
end;
错误:
[dcc32 错误] uMain.pas(74):E2010 不兼容的类型:“TNotifyEvent”和“过程、无类型指针或无类型参数”
怎么了?谢谢!