home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 September / Chip_2001-09_cd1.bin / zkuste / delphi / kolekce / d12345 / MISC.ZIP / Splash.pas < prev    next >
Pascal/Delphi Source File  |  2001-05-02  |  6KB  |  219 lines

  1. unit Splash;
  2.  
  3. {-----------------------------------------------------------------------------
  4. The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
  5.  
  6. http://www.mozilla.org/MPL/MPL-1.1.html
  7.  
  8. Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for the specific language governing rights and limitations under the License.
  9.  
  10. The Original Code is: Splash.pas, released 12 September 2000.
  11.  
  12. The Initial Developer of the Original Code is Mat Ballard.
  13. Portions created by Mat Ballard are Copyright (C) 1999 Mat Ballard.
  14. Portions created by Microsoft are Copyright (C) 1998, 1999 Microsoft Corp.
  15. All Rights Reserved.
  16.  
  17. Contributor(s): Mat Ballard                 e-mail: mat.ballard@chemware.hypermart.net.
  18.  
  19. Last Modified: 05/25/2000
  20. Current Version: 2.00
  21.  
  22. You may retrieve the latest version of this file from:
  23.  
  24.         http://Chemware.hypermart.net/
  25.  
  26. This work was created with the Project JEDI VCL guidelines:
  27.  
  28.         http://www.delphi-jedi.org/Jedi:VCLVCL
  29.  
  30. in mind. 
  31.  
  32.  
  33. Purpose:
  34. This file contains the SplashBox form.
  35. This form is used to display a standard "Splash" dialog box with a few extra wrinkles.
  36.  
  37. Known Issues:
  38. -----------------------------------------------------------------------------}
  39.  
  40. interface
  41.  
  42. uses
  43.   FileInfo,
  44.   Classes, SysUtils, IniFiles,
  45. {$IFDEF WINDOWS}
  46.   WinTypes, WinProcs, ShellAPI,
  47.   Buttons, Controls, ExtCtrls, Forms, Graphics, StdCtrls
  48. {$ENDIF}
  49. {$IFDEF WIN32}
  50.   Windows, ShellAPI,
  51.   Buttons, Controls, ExtCtrls, Forms, Graphics, StdCtrls
  52. {$ENDIF}
  53. {$IFDEF LINUX}
  54.   QTypes,
  55.   QButtons, QControls, QExtCtrls, QForms, QGraphics, QStdCtrls
  56. {$ENDIF}
  57.   ;
  58.  
  59. type
  60.   TSplashBox = class(TForm)
  61.     Panel1: TPanel;
  62.     ProgramIcon: TImage;
  63.     ProductLabel: TLabel;
  64.     VersionLabel: TLabel;
  65.     CopyrightLabel: TLabel;
  66.     URLLabel: TLabel;
  67.     CommentsLabel: TLabel;
  68.     LeftImage: TImage;
  69.     RightImage: TImage;
  70.     PriceLabel: TLabel;
  71.     AgreeBitBtn: TBitBtn;
  72.     DisagreeBitBtn: TBitBtn;
  73.     ViewLicenseBitBtn: TBitBtn;
  74.     CompanyLabel: TLabel;
  75.     Timer1: TTimer;
  76.     procedure FormShow(Sender: TObject);
  77.     procedure URLLabelClick(Sender: TObject);
  78.     procedure OpenObject(sObjectPath : PChar);
  79.     procedure ProgramIconClick(Sender: TObject);
  80.     procedure ViewLicenseBitBtnClick(Sender: TObject);
  81.     procedure FormCreate(Sender: TObject);
  82.     procedure Timer1Timer(Sender: TObject);
  83.   private
  84.     Registered: Boolean;
  85.     CompanyName: String;
  86.     procedure GetRegistration;
  87.   public
  88.     { Public declarations }
  89.   end;
  90.  
  91. var
  92.   SplashBox: TSplashBox;
  93.   {This is the "Splash" dialog box that TSplashDlg displays
  94.    when its Execute function is called.}
  95.   {}
  96.   {As well as the properties mentioned elsewhere, it also shows the
  97.    free resources and operating system.}
  98.  
  99. implementation
  100.  
  101. {$R *.dfm}
  102.  
  103. {------------------------------------------------------------------------------
  104.     Procedure: TSplashBox.FormShow
  105.   Description: standard FormShow event handler
  106.        Author: Mat Ballard
  107.  Date created: 04/25/2000
  108. Date modified: 04/25/2000 by Mat Ballard
  109.       Purpose: sets the Position on screen
  110.  Known Issues:
  111.  ------------------------------------------------------------------------------}
  112. procedure TSplashBox.FormShow(Sender: TObject);
  113. begin
  114.   Left := (Screen.Width - Width) div 2;
  115.   Top := (Screen.Height - Height) div 2;
  116. end;
  117.  
  118. procedure TSplashBox.URLLabelClick(Sender: TObject);
  119. var
  120.   TempString : array[0..255] of char;
  121. begin
  122.   StrPCopy(TempString,URLLabel.Caption);
  123.   OpenObject(TempString);
  124. end;
  125.  
  126. procedure TSplashBox.OpenObject(sObjectPath : PChar);
  127. begin
  128. {$IFDEF WINDOWS}
  129.   ShellExecute(0, Nil, sObjectPath, Nil, Nil, 3);  {?SW_SHOW ?}
  130. {$ENDIF}
  131. {$IFDEF WIN32}
  132.   ShellExecute(0, Nil, sObjectPath, Nil, Nil, SW_NORMAL);
  133. {$ENDIF}
  134. {$IFDEF LINUX}
  135.   //
  136. {$ENDIF}
  137. end;
  138.  
  139. procedure TSplashBox.ProgramIconClick(Sender: TObject);
  140. begin
  141.   OpenObject('http://www.borland.com/delphi/');
  142. end;
  143.  
  144. procedure TSplashBox.ViewLicenseBitBtnClick(Sender: TObject);
  145. begin
  146. {$IFDEF MSWINDOWS}
  147.   Application.HelpContext(HelpContext);
  148.   //Application.HelpJump(HelpContext);
  149. {$ENDIF}
  150. end;
  151.  
  152. procedure TSplashBox.FormCreate(Sender: TObject);
  153. var
  154.   Info: TFileVersionInfo;
  155. begin
  156. {$IFDEF MSWINDOWS}
  157.   //Self.PixelsPerInch := 96;
  158.   Self.BorderStyle := bsDialog;
  159. {$ENDIF}
  160. {$IFDEF LINUX}
  161.   //Self.PixelsPerInch := 75;
  162.   Self.BorderStyle := fbsDialog;
  163. {$ENDIF}
  164.  
  165.   Left := Screen.Width - Self.Width div 2;
  166.   Top := Screen.Height - Self.Height div 2;
  167.   ClientHeight := AgreeBitBtn.Top + 3 * AgreeBitBtn.Height div 2;
  168.   ClientWidth := Panel1.Left + Panel1.Width + Panel1.Left;
  169.   AgreeBitBtn.Left := (Self.ClientWidth - AgreeBitBtn.Width) div 2;
  170.  
  171. {get version information:}
  172.   Info := TFileVersionInfo.Create(self);
  173.   Info.ExecutableFile := Application.ExeName;
  174.   ProductLabel.Caption := Info.ProductName;
  175.   CompanyName := Info.CompanyName;
  176.   CompanyLabel.Caption := 'by ' + Info.CompanyName;
  177.   VersionLabel.Caption := 'Version ' + Info.FileVersion;
  178.   CopyrightLabel.Caption := Info.LegalCopyright;
  179.   CommentsLabel.Caption := Info.Comments;
  180.   Info.Free;
  181.   GetRegistration;
  182. end;
  183.  
  184. procedure TSplashBox.Timer1Timer(Sender: TObject);
  185. begin
  186.   ModalResult := mrOk;
  187. end;
  188.  
  189. procedure TSplashBox.GetRegistration;
  190. var
  191.   Reg: TIniFile;
  192.   FileName: String;
  193.   Value: String;
  194. begin
  195.   FileName := Copy(Application.ExeName, 1, Length(Application.ExeName)-4) +
  196.     'ini';
  197.   Reg := TIniFile.Create(FileName);
  198.   Try
  199.     Value := Reg.ReadString(CompanyName, 'Registered', '0');
  200.     if (Value = '1') then
  201.     begin
  202.       Registered := TRUE;
  203.       PriceLabel.Caption := 'Registered to ' + #13+#10 +
  204.         Reg.ReadString(CompanyName, 'Username', 'UnRegistered');
  205.       LeftImage.Visible := FALSE;
  206.       RightImage.Visible := FALSE;
  207.       PriceLabel.Left := LeftImage.Left;
  208.       PriceLabel.Width := RightImage.Left + RightImage.Width - LeftImage.Left;
  209.     end;
  210.   finally
  211.     Reg.Free;
  212.   end;
  213. end;
  214.  
  215.  
  216. end.
  217.  
  218.  
  219.