搞定了,我原是不懂(sender as ...)可以获得控件自身的信息!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, ximage,pngimage;
type
TForm1 = class(TForm)
x: tximage;
about: tximage;
procedure xMouseEnter(Sender: TObject);
procedure xMouseLeave(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.xMouseEnter(Sender: TObject);
var s:string;
begin
s:=(sender as tximage).Name;
(sender as tximage).Picture.LoadFromFile('D:/My Documents/My Pictures/'+s+'_1.png');
end;
procedure TForm1.xMouseLeave(Sender: TObject);
var s:string;
begin
s:=(sender as tximage).Name;
(sender as tximage).Picture.LoadFromFile('D:/My Documents/My Pictures/'+s+'_2.png');
end;
end.