home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1997 May / VPR9705A.ISO / VPR_DATA / PROGRAM / Delphi / Sample / ABOUTBOX.PAS < prev    next >
Pascal/Delphi Source File  |  1997-03-02  |  2KB  |  91 lines

  1. unit AboutBox;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls, Buttons, ExtCtrls;
  8.  
  9. type
  10.   TAboutBoxForm = class(TForm)
  11.     Panel1: TPanel;
  12.     ProgramIcon: TImage;
  13.     ProductName: TLabel;
  14.     Version: TLabel;
  15.     Copyright: TLabel;
  16.     BitBtn1: TBitBtn;
  17.   private
  18.     { Private 宣言 }
  19.   public
  20.     { Public 宣言 }
  21.   end;
  22.  
  23.   TAboutBox = class(TComponent)
  24.   private
  25.     FCopyright: string;
  26.     FProductName: string;
  27.     FProgramIcon: TIcon;
  28.     FVersion: string;
  29.     procedure SetProgramIcon(Value: TIcon);
  30.   public
  31.     constructor Create(AOwner: TComponent); override;
  32.     destructor Destroy; override;
  33.     procedure Execute;
  34.   published
  35.     property Copyright: string read FCopyright write FCopyright;
  36.     property ProductName: string read FProductName write FProductName;
  37.     property ProgramIcon: TIcon read FProgramIcon write SetProgramIcon;
  38.     property Version: string read FVersion write FVersion;
  39.   end;
  40.  
  41. var
  42.   AboutBoxForm: TAboutBoxForm;
  43.  
  44. procedure Register;
  45.  
  46. implementation
  47.  
  48. {$R *.DFM}
  49.  
  50. constructor TAboutBox.Create(AOwner: TComponent);
  51. begin
  52.   inherited Create(AOwner);
  53.   FProgramIcon := TIcon.Create;
  54. end;
  55.  
  56. destructor TAboutBox.Destroy;
  57. begin
  58.   FProgramIcon.Free;
  59.   inherited Destroy;
  60. end;
  61.  
  62. procedure TAboutBox.SetProgramIcon(Value: TIcon);
  63. begin
  64.   FProgramIcon.Assign(Value);
  65. end;
  66.  
  67. procedure TAboutBox.Execute;
  68. begin
  69.   AboutBoxForm := TAboutBoxForm.Create(Application);
  70.   with AboutBoxForm do
  71.   begin
  72.     if FProductName = '' then
  73.       ProductName.Caption := ExtractFileName(Application.ExeName)
  74.     else
  75.       AboutBoxForm.ProductName.Caption := FProductName;
  76.     Version.Caption := FVersion;
  77.     Copyright.Caption := FCopyright;
  78.     if not FProgramIcon.Empty then
  79.       ProgramIcon.Picture.Assign(FProgramIcon);
  80.     ShowModal;
  81.     Free;
  82.   end;
  83. end;
  84.  
  85. procedure Register;
  86. begin
  87.   RegisterComponents('Samples', [TAboutBox]);
  88. end;
  89.  
  90. end.
  91.