Пытаюсь сделать так, чтобы при наведении мышки на картинку, она изменялась на другую.
Правильно ли то, что я использую OnMouseMove? Как это сделать?
Image1.Picture := ????????;
var
Form1: TForm1;
pics:array[1..piccount] of string=('pictures\1.jpg','pictures\2.jpg');
implementation
{$R *.dfm}
procedure TForm1.Image1MouseEnter(Sender: TObject);
begin
image1.Picture.LoadFromfile(pics[1]);
end;
procedure TForm1.Image1MouseLeave(Sender: TObject);
begin
image1.Picture.LoadFromfile(pics[2]);
end;
end.
var mmove:boolean=false;
implementation
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if mmove then begin
mmove:=false;
image1.Picture.LoadFromFile(pics[2]);
end;
end;
procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if not(mmove) then begin
mmove:=true;
image1.Picture.LoadFromFile(pics[1]);
end;
end;
var
Form1: TForm1;
pics:array[1..2] of string=('.\1.jpg', '.\2.jpg');
mmove:boolean=false;
implementation
{$R *.dfm}
procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if not(mmove) then begin
mmove:=true;
image1.Picture.LoadFromFile(pics[1]);
end;
end;
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if mmove then begin
mmove:=false;
image1.Picture.LoadFromFile(pics[2]);
end;
end;
var
pics:array[1..2] of string=('1.jpg', '2.jpg');
// ...
function FullPath(p: string): string;
begin
result := ExtractFilePath(Application.ExeName) + p;
end;
// ...
image1.Picture.LoadFromFile(FullPath(pics[1]));
pics:array[1..2] of string=('D:\Pr\1.jpeg', 'D:\Pr\2.jpg');
procedure TForm1.Image1MouseEnter(Sender: TObject);
begin
image1.Picture.LoadFromfile(pics[1]);
end;
procedure TForm1.Image1MouseLeave(Sender: TObject);
begin
image1.Picture.LoadFromfile(pics[2]);
end;
procedure TForm1.Image1MouseEnter(Sender: TObject);
begin
image1.Picture := Buf1.Picture;
end;
procedure TForm1.Image1MouseLeave(Sender: TObject);
begin
image1.Picture := Buf2.Picture;
end;
var
Form1: TForm1;
pics:array[1..piccount] of string=('pictures\1.jpg','pictures\2.jpg');
implementation
{$R *.dfm}
procedure TForm1.Image1MouseEnter(Sender: TObject);
begin
image1.Picture.LoadFromfile(pics[1]);
end;
procedure TForm1.Image1MouseLeave(Sender: TObject);
begin
image1.Picture.LoadFromfile(pics[2]);
end;
end.
NameS[1] := 'Pictures/1.bmp';
NameS[2] := 'Pictures/2.bmp';
NameS[3] := 'Pictures/3.bmp';
Sprite.LoadFromFile(NameS[1]);
Sprite.Picture.LoadFromFile(NameS[1]);