u_form.pas

来自「很好地delphi书籍源码」· PAS 代码 · 共 51 行

PAS
51
字号
unit U_Form;

interface

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

type
  TForm1 = class(TForm)
    LookupButton: TButton;
    DriveCB: TDriveComboBox;
    DirListBox1: TDirectoryListBox;
    ExtCB: TComboBox;
    DirLabel: TLabel;
    ExitButton: TButton;
    ListBox1: TListBox;
    procedure LookupButtonClick(Sender: TObject);
    procedure ExitButtonClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.LookupButtonClick(Sender: TObject);
var
  sr:TSearchRec;
begin
  ListBox1.Clear;
  if FindFirst(DirLabel.Caption+'\'+ExtCB.Text,faAnyFile,sr)=0 then
    ListBox1.Items.Add(sr.Name+'   '+IntToStr(sr.Size)+'字节');
  while (FindNext(sr)=0) do
    ListBox1.Items.Add(sr.Name+'   '+IntToStr(sr.Size)+'字节');
  FindClose(sr);
end;

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

end.

⌨️ 快捷键说明

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