掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
表示されている画像を消して別の画像を表示するには? (ID:44193)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
こんな感じで目的の動作はするのですが画像を増やせば増やすほど冗長になる気がします。どうすればもっと綺麗に書けますか? unit Unit1; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Imaging.pngimage, Vcl.ExtCtrls, Vcl.StdCtrls; type TForm1 = class(TForm) Button1: TButton; Image1: TImage; Image2: TImage; Image3: TImage; Image4: TImage; procedure Button1Click(Sender: TObject); private { Private 宣言 } public { Public 宣言 } end; var Form1: TForm1; i: integer; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin i := i + 1; if i = 1 then begin Image1.Visible := true; end; if i = 2 then begin Image2.Visible := true; Image1.Visible := false; end; if i = 3 then begin Image3.Visible := true; Image2.Visible := false; end; if i = 4 then begin Image4.Visible := true; Image3.Visible := false; end; end; end.
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.