unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Image1: TImage;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
image1.Height:=200;
image1.Width:=200;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
image1.Canvas.Brush.Color:=clred;
image1.Canvas.FillRect(rect(0,0,100,100));
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
image1.Height:=400;
image1.Width:=400;
image1.Canvas.FillRect(rect(200,200,300,300));
image1.Refresh;
image1.Repaint;
image1.Invalidate;
end;
end.
上面的程序,在按button1后再按button2,那button2所画的东西就看不到.Why ????