⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainform.pas

📁 delphi com深入编程,非常有收藏价值
💻 PAS
字号:
unit MainForm;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, SummInfo, Menus, ExtCtrls, ComCtrls;

type
  TForm1 = class(TForm)
    SummaryInformation1: TSummaryInformation;
    OpenDialog1: TOpenDialog;
    MainMenu1: TMainMenu;
    File1: TMenuItem;
    FileOpen1: TMenuItem;
    N1: TMenuItem;
    FileExit1: TMenuItem;
    list: TListView;
    Panel1: TPanel;
    Bevel1: TBevel;
    procedure FileExit1Click(Sender: TObject);
    procedure FileOpen1Click(Sender: TObject);
  private
    { Private declarations }
    procedure DisplaySummaryInformation(AFileName: string);
    procedure AddIntegerProperty(AProperty: string;
      AValue: Integer; AUnits: string);
    procedure AddStringProperty(AProperty, AValue: string);
    procedure AddDateProperty(AProperty: string; AValue: TDateTime);
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FileExit1Click(Sender: TObject);
begin
  Close;
end;

procedure TForm1.AddStringProperty(AProperty: string; AValue: string);
var
  Item: TListItem;
begin
  Item := list.Items.Add;
  Item.Caption := AProperty;
  Item.SubItems.Add(AValue);
end;

procedure TForm1.AddIntegerProperty(AProperty: string;
  AValue: Integer; AUnits: string);
var
  Item: TListItem;
begin
  Item := list.Items.Add;
  Item.Caption := AProperty;
  Item.SubItems.Add(IntToStr(AValue) + ' ' + AUnits);
end;

procedure TForm1.AddDateProperty(AProperty: string; AValue: TDateTime);
var
  Item: TListItem;
begin
  Item := list.Items.Add;
  Item.Caption := AProperty;
  if AValue <> 0 then
    Item.SubItems.Add(FormatDateTime('dddddd tt', AValue));
end;

procedure TForm1.DisplaySummaryInformation(AFileName: string);
begin
  SummaryInformation1.FileName := AFileName;
  SummaryInformation1.Open;
  try
    list.Items.BeginUpdate;
    try
      list.Items.Clear;
      AddStringProperty('App Name', SummaryInformation1.AppName);
      AddStringProperty('Author', SummaryInformation1.Author);
      AddIntegerProperty('Char Count', SummaryInformation1.CharCount,
        'characters');
      AddStringProperty('Comments', SummaryInformation1.Comments);
      AddDateProperty('Created', SummaryInformation1.Created);
      AddStringProperty('Document Security', SummaryInformation1.DocSecurity);
      AddStringProperty('Document Name', SummaryInformation1.DocumentName);
      AddIntegerProperty('Edit Time', SummaryInformation1.EditTime,
        'minutes');
      AddStringProperty('File Name', SummaryInformation1.FileName);
      AddStringProperty('Keywords', SummaryInformation1.Keywords);
      AddStringProperty('Last Author', SummaryInformation1.LastAuthor);
      AddDateProperty('Last Printed', SummaryInformation1.LastPrinted);
      AddDateProperty('Last Saved', SummaryInformation1.LastSaved);
      AddIntegerProperty('Page Count', SummaryInformation1.PageCount,
        'pages');
      AddStringProperty('Revision Number', SummaryInformation1.RevisionNumber);
      AddStringProperty('Subject', SummaryInformation1.Subject);
      AddStringProperty('Template', SummaryInformation1.Template);
      AddStringProperty('Title', SummaryInformation1.Title);
      AddIntegerProperty('Word Count', SummaryInformation1.WordCount,
        'words');
    finally
      list.Items.EndUpdate;
    end;
  finally
    SummaryInformation1.Close;
  end;
end;

procedure TForm1.FileOpen1Click(Sender: TObject);
begin
  if OpenDialog1.Execute then
    DisplaySummaryInformation(OpenDialog1.FileName);
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -