Показать сообщение отдельно
  #6  
Старый 06.07.2019, 22:09
DDim1000 DDim1000 вне форума
Прохожий
 
Регистрация: 28.12.2012
Сообщения: 18
Репутация: 10
Счастье

Почему при нажатии на кнопки картинка исчезает?:
Код:
unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, ieview, imageenview, imageen,
  Vcl.StdCtrls, Vcl.ExtCtrls;

type
  TForm1 = class(TForm)
    Image1: TImage;
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure ResizeImage;
  private
    { Private declarations }
      ImgScale : Double; // default 1.0 - set in OnCreate
      ImgSize : TPoint; // Width and Height of original image, set when load image
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  ImgScale := ImgScale * 2;
  ResizeImage;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  ImgScale := ImgScale / 2;
  ResizeImage;
end;

procedure TForm1.ResizeImage;
begin
  Image1.Width := Round(ImgSize.x*ImgScale);
  Image1.Height := Round(ImgSize.y*ImgScale);
end;

end.
Ответить с цитированием