打开图片

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtDlgs, ExtCtrls, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Image1: TImage;
    OpenPictureDialog1: TOpenPictureDialog;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  openfilepath: string;
begin
  if openpicturedialog1.Execute then               //打开图片对话框
  begin
    openfilepath := openpicturedialog1.FileName;   //在对话框中选择图片文件
    image1.Picture.LoadFromFile(openfilepath);     //图片装入Image1中
  end;
end;

end.

 

posted @ 2011-12-10 22:24  endsnow  阅读(431)  评论(0)    收藏  举报