W
wind_2005
Unregistered / Unconfirmed
GUEST, unregistred user!
我在TImage控件上通过Canvas画图,但是在增加了TImage控件的宽、高后,重画的图(图随着TImage控件的宽、高自动增大)只能显示原始TImage尺寸范围内的图形,为什么?还望各位多多指教,谢谢!代码如下:=============================unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls;type TForm1 = class(TForm) Button2: TButton; Button3: TButton; Image1: TImage; procedure Button2Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure Button3Click(Sender: TObject); private procedure Draw; { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button2Click(Sender: TObject);begin //此处放大了Image1,按Image1的大小重画后,超出原始Image1尺寸的一部分不可见 Image1.Width := Image1.Width + 10; Image1.Height := Image1.Height + 10; Draw;end;procedure TForm1.FormCreate(Sender: TObject);begin Image1.Canvas.Pen.Color := clBlack; Image1.Canvas.Pen.Width := 5; Draw;end;procedure TForm1.Button3Click(Sender: TObject);begin //此处缩小了Image1,重画后显示正常 Image1.Width := Image1.Width - 10; Image1.Height := Image1.Height - 10; Draw;end;procedure TForm1.Draw;begin Image1.Canvas.Rectangle(0,0, Image1.Width, Image1.Height);end;end.