公共对话框示例

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Label1: TLabel;
    OpenDialog1: TOpenDialog;
    SaveDialog1: TSaveDialog;
    FontDialog1: TFontDialog;
    ColorDialog1: TColorDialog;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  if opendialog1.Execute then
    label1.Caption := opendialog1.FileName;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  if savedialog1.Execute then
    label1.Caption := savedialog1.FileName;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  if fontdialog1.Execute then
    label1.Font := fontdialog1.Font;
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
  if colordialog1.Execute then
    label1.Color := colordialog1.Color;
end;

end.

 

posted @ 2011-12-06 09:06  endsnow  阅读(158)  评论(0)    收藏  举报