5,392
社区成员
发帖
与我相关
我的任务
分享
procedure TMainForm.open1Click(Sender: TObject);
var
bm: TBitmap;
begin
if OpenPictureDialog1.Execute then
begin
bm := TBitmap.Create;
bm.LoadFromFile(OpenPictureDialog1.FileName);
Image1.Picture.LoadFromFile(OpenPictureDialog1.FileName);
PaintBox1.Canvas.CopyRect(Rect(PaintBox1.Left, PaintBox1.Top,
PaintBox1.Width, PaintBox1.Height), bm.Canvas,
Rect(0, 0, bm.Width, bm.Height));
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Image1.AutoSize := True;
Image1.Left := 0;
Image1.Top := 0;
ScrollBox1.HorzScrollBar.Tracking := True;
ScrollBox1.VertScrollBar.Tracking := True;
end;
Step 3:
procedure TForm1.Button4Click(Sender: TObject);
begin
if OpenPictureDialog1.Execute then
if FileExists(OpenPictureDialog1.FileName) then
Image1.Picture.LoadFromFile(OpenPictureDialog1.FileName)
else
raise Exception.Create('圖檔不存在.');
end;