ShowLog.pas
上传用户:rickyhu
上传日期:2007-05-27
资源大小:842k
文件大小:2k
源码类别:

控制台编程

开发平台:

Delphi

  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // 2004 (C) Copyrights Reserved
  4. // Author:Aureala
  5. //
  6. ////////////////////////////////////////////////////////////////////////////////
  7. unit ShowLog;
  8. interface
  9. uses
  10.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  11.   Dialogs, ExtCtrls, ComCtrls, StdCtrls, UtilTools;
  12. type
  13.   TShowLogForm = class(TForm)
  14.     Panel1: TPanel;
  15.     LVLog: TListView;
  16.     Panel2: TPanel;
  17.     BtnSelectLog: TButton;
  18.     OpenDialog: TOpenDialog;
  19.     Label16: TLabel;
  20.     CBClient: TComboBox;
  21.     Label7: TLabel;
  22.     CBViewItem: TComboBox;
  23.     BtnView: TButton;
  24.     procedure BtnSelectLogClick(Sender: TObject);
  25.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  26.     procedure CBClientChange(Sender: TObject);
  27.     procedure CBViewItemChange(Sender: TObject);
  28.     procedure BtnViewClick(Sender: TObject);
  29.     procedure FormCreate(Sender: TObject);
  30.   private
  31.     { Private declarations }
  32.   public
  33.     { Public declarations }
  34.   end;
  35. var
  36.   ShowLogForm: TShowLogForm;
  37. implementation
  38. {$R *.dfm}
  39. procedure TShowLogForm.BtnSelectLogClick(Sender: TObject);
  40. begin
  41.   OpenDialog.Title:='查看计算机监视日志记录';
  42.   OpenDialog.Filter:='日志记录|*.rec';
  43.   OpenDialog.InitialDir:=ExtractFilePath(ParamStr(0)+'log');
  44.   OpenDialog.Execute;
  45.   if(OpenDialog.FileName<>'') then
  46.   begin
  47.     BtnView.Click;
  48.   end;
  49. end;
  50. procedure TShowLogForm.FormClose(Sender: TObject;
  51.   var Action: TCloseAction);
  52. begin
  53.   Close;
  54.   Release;
  55. end;
  56. procedure TShowLogForm.CBClientChange(Sender: TObject);
  57. begin
  58.   BtnView.Click;
  59. end;
  60. procedure TShowLogForm.CBViewItemChange(Sender: TObject);
  61. begin
  62.   BtnView.Click;
  63. end;
  64. procedure TShowLogForm.BtnViewClick(Sender: TObject);
  65. begin
  66.   try
  67.     LoadLog(OpenDialog.FileName,CBClient.Text,CBViewItem.ItemIndex,LVLog);
  68.   except
  69.     ;
  70.   end;
  71.   if(LVLog.Items.Count<=0) then
  72.     ShowMessage('没有你要查看的日志记录!');
  73. end;
  74. procedure TShowLogForm.FormCreate(Sender: TObject);
  75. begin
  76.   UpdateClient(CBClient);
  77.   CBClient.Items.Strings[0]:='全部';
  78.   CBClient.ItemIndex:=0;
  79. end;
  80. end.