home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 October / Chip_2001-10_cd1.bin / zkuste / delphi / kompon / d123456 / CHEMPLOT.ZIP / Misc / Splash.pas < prev    next >
Pascal/Delphi Source File  |  2001-07-24  |  8KB  |  280 lines

  1. unit Splash;
  2.  
  3. {$I Misc.inc}
  4.  
  5. {-----------------------------------------------------------------------------
  6. 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
  7.  
  8. http://www.mozilla.org/MPL/MPL-1.1.html
  9.  
  10. 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.
  11.  
  12. The Original Code is: Splash.pas, released 12 September 2000.
  13.  
  14. The Initial Developer of the Original Code is Mat Ballard.
  15. Portions created by Mat Ballard are Copyright (C) 1999 Mat Ballard.
  16. Portions created by Microsoft are Copyright (C) 1998, 1999 Microsoft Corp.
  17. All Rights Reserved.
  18.  
  19. Contributor(s): Mat Ballard                 e-mail: mat.ballard@chemware.hypermart.net.
  20.  
  21. Last Modified: 05/25/2000
  22. Current Version: 2.00
  23.  
  24. You may retrieve the latest version of this file from:
  25.  
  26.         http://Chemware.hypermart.net/
  27.  
  28. This work was created with the Project JEDI VCL guidelines:
  29.  
  30.         http://www.delphi-jedi.org/Jedi:VCLVCL
  31.  
  32. in mind. 
  33.  
  34.  
  35. Purpose:
  36. This file contains the SplashBox form.
  37. This form is used to display a standard "Splash" dialog box with a few extra wrinkles.
  38.  
  39. Known Issues:
  40. -----------------------------------------------------------------------------}
  41.  
  42. interface
  43.  
  44. uses
  45.   FileInfo,
  46.   Classes, SysUtils, IniFiles,
  47. {$IFDEF WINDOWS}
  48.   WinTypes, WinProcs, ShellAPI,
  49.   Buttons, Controls, ExtCtrls, Forms, Graphics, StdCtrls,
  50. {$ENDIF}
  51. {$IFDEF WIN32}
  52.   Windows, ShellAPI,
  53.   Buttons, Controls, ExtCtrls, Forms, Graphics, StdCtrls,
  54. {$ENDIF}
  55. {$IFDEF LINUX}
  56.   QTypes,
  57.   QButtons, QControls, QExtCtrls, QForms, QGraphics, QStdCtrls,
  58. {$ENDIF}
  59.   Misc;
  60.  
  61. type
  62.   TSplashBox = class(TForm)
  63.     Panel1: TPanel;
  64.     ProductLabel: TLabel;
  65.     VersionLabel: TLabel;
  66.     CopyrightLabel: TLabel;
  67.     URLLabel: TLabel;
  68.     CommentsLabel: TLabel;
  69.     LeftImage: TImage;
  70.     RightImage: TImage;
  71.     PriceLabel: TLabel;
  72.     AgreeBitBtn: TBitBtn;
  73.     DisagreeBitBtn: TBitBtn;
  74.     ViewLicenseBitBtn: TBitBtn;
  75.     CompanyLabel: TLabel;
  76.     Timer1: TTimer;
  77.     procedure FormShow(Sender: TObject);
  78.     procedure URLLabelClick(Sender: TObject);
  79.     procedure OpenObject(sObjectPath : PChar);
  80.     procedure ProgramIconClick(Sender: TObject);
  81.     procedure ViewLicenseBitBtnClick(Sender: TObject);
  82.     procedure FormCreate(Sender: TObject);
  83.     procedure Timer1Timer(Sender: TObject);
  84.   private
  85.     Registered: Boolean;
  86.     CompanyName: String;
  87.     ProgramIcon: TImage;
  88.     procedure GetRegistration;
  89.   public
  90. {$IFNDEF LANG_ENGLISH}
  91.     procedure DoCaptionsFromResource;
  92. {$ENDIF}
  93.     procedure DoHintsFromResource;
  94.   end;
  95.  
  96. var
  97.   SplashBox: TSplashBox;
  98.   {This is the "Splash" dialog box that TSplashDlg displays
  99.    when its Execute function is called.}
  100.   {}
  101.   {As well as the properties mentioned elsewhere, it also shows the
  102.    free resources and operating system.}
  103.  
  104. implementation
  105.  
  106. {$R *.dfm}
  107.  
  108. {------------------------------------------------------------------------------
  109.     Procedure: TSplashBox.FormCreate
  110.   Description: standard FormCreate procedure
  111.        Author: Mat Ballard
  112.  Date created: 04/25/2000
  113. Date modified: 04/25/2000 by Mat Ballard
  114.       Purpose: sets the position and fills the labels
  115.  Known Issues:
  116.  ------------------------------------------------------------------------------}
  117. procedure TSplashBox.FormCreate(Sender: TObject);
  118. var
  119.   Info: TFileVersionInfo;
  120. begin
  121.   ProgramIcon := TImage.Create(Self);
  122.   ProgramIcon.Parent := Panel1;
  123.   ProgramIcon.Left := 8;
  124.   ProgramIcon.Top := 8;
  125.   ProgramIcon.AutoSize := TRUE;
  126.   ProgramIcon.Picture.Bitmap.LoadFromResourceID(hInstance, 100);
  127.  
  128. {$IFNDEF LANG_ENGLISH}
  129.   DoCaptionsFromResource;
  130. {$ENDIF}
  131.   DoHintsFromResource;
  132.  
  133. {$IFDEF MSWINDOWS}
  134.   //Self.PixelsPerInch := 96;
  135.   Self.BorderStyle := bsDialog;
  136. {$ENDIF}
  137. {$IFDEF LINUX}
  138.   //Self.PixelsPerInch := 75;
  139.   Self.BorderStyle := fbsDialog;
  140. {$ENDIF}
  141.  
  142.   Left := Screen.Width - Self.Width div 2;
  143.   Top := Screen.Height - Self.Height div 2;
  144.   ClientHeight := AgreeBitBtn.Top + 3 * AgreeBitBtn.Height div 2;
  145.   ClientWidth := Panel1.Left + Panel1.Width + Panel1.Left;
  146.   AgreeBitBtn.Left := (Self.ClientWidth - AgreeBitBtn.Width) div 2;
  147.  
  148. {get version information:}
  149.   Info := TFileVersionInfo.Create(self);
  150.   Info.ExecutableFile := Application.ExeName;
  151.   ProductLabel.Caption := Info.ProductName;
  152.   CompanyName := Info.CompanyName;
  153.   CompanyLabel.Caption := sBy  + Info.CompanyName;
  154.   VersionLabel.Caption := sVersion + ' ' + Info.FileVersion;
  155.   CopyrightLabel.Caption := Info.LegalCopyright;
  156.   CommentsLabel.Caption := Info.Comments;
  157.   Info.Free;
  158.   GetRegistration;
  159. end;
  160.  
  161. {------------------------------------------------------------------------------
  162.     Procedure: TSplashBox.DoCaptionsFromResource
  163.   Description: standard loading of labels from resources
  164.        Author: Mat Ballard
  165.  Date created: 06/25/2001
  166. Date modified: 06/25/2001 by Mat Ballard
  167.       Purpose: display in different languages
  168.  Known Issues:
  169.  ------------------------------------------------------------------------------}
  170. {$IFNDEF LANG_ENGLISH}
  171. procedure TSplashBox.DoCaptionsFromResource;
  172. begin
  173.   ViewLicenseBitBtn.Caption := sViewLicense;
  174.   AgreeBitBtn.Caption := sIAgree;
  175.   DisAgreeBitBtn.Caption := sIDisAgree;
  176. end;
  177. {$ENDIF}
  178.  
  179. {------------------------------------------------------------------------------
  180.     Procedure: TSplashBox.DoHintsFromResource
  181.   Description: standard loading of hints from resources
  182.        Author: Mat Ballard
  183.  Date created: 06/25/2001
  184. Date modified: 06/25/2001 by Mat Ballard
  185.       Purpose: display hints in different languages
  186.  Known Issues:
  187.  ------------------------------------------------------------------------------}
  188. procedure TSplashBox.DoHintsFromResource;
  189. begin
  190.   URLLabel.Hint := sURLLabelHint;
  191.   ProgramIcon.Hint := sProgramIconHint;
  192.   ViewLicenseBitBtn.Hint := sViewLicenseBitBtnHint;
  193.   AgreeBitBtn.Hint := sIAgreeBitBtnHint;
  194. end;
  195.  
  196. {------------------------------------------------------------------------------
  197.     Procedure: TSplashBox.FormShow
  198.   Description: standard FormShow event handler
  199.        Author: Mat Ballard
  200.  Date created: 04/25/2000
  201. Date modified: 04/25/2000 by Mat Ballard
  202.       Purpose: sets the Position on screen
  203.  Known Issues:
  204.  ------------------------------------------------------------------------------}
  205. procedure TSplashBox.FormShow(Sender: TObject);
  206. begin
  207.   Left := (Screen.Width - Width) div 2;
  208.   Top := (Screen.Height - Height) div 2;
  209. end;
  210.  
  211. procedure TSplashBox.URLLabelClick(Sender: TObject);
  212. var
  213.   TempString : array[0..255] of char;
  214. begin
  215.   StrPCopy(TempString,URLLabel.Caption);
  216.   OpenObject(TempString);
  217. end;
  218.  
  219. procedure TSplashBox.OpenObject(sObjectPath : PChar);
  220. begin
  221. {$IFDEF WINDOWS}
  222.   ShellExecute(0, Nil, sObjectPath, Nil, Nil, 3);  {?SW_SHOW ?}
  223. {$ENDIF}
  224. {$IFDEF WIN32}
  225.   ShellExecute(0, Nil, sObjectPath, Nil, Nil, SW_NORMAL);
  226. {$ENDIF}
  227. {$IFDEF LINUX}
  228.   //
  229. {$ENDIF}
  230. end;
  231.  
  232. procedure TSplashBox.ProgramIconClick(Sender: TObject);
  233. begin
  234.   OpenObject('http://www.borland.com/delphi/');
  235. end;
  236.  
  237. procedure TSplashBox.ViewLicenseBitBtnClick(Sender: TObject);
  238. begin
  239. {$IFDEF MSWINDOWS}
  240.   Application.HelpContext(HelpContext);
  241.   //Application.HelpJump(HelpContext);
  242. {$ENDIF}
  243. end;
  244.  
  245. procedure TSplashBox.Timer1Timer(Sender: TObject);
  246. begin
  247.   ModalResult := mrOk;
  248. end;
  249.  
  250. procedure TSplashBox.GetRegistration;
  251. var
  252.   Reg: TIniFile;
  253.   FileName: String;
  254.   Value: String;
  255. begin
  256.   FileName := Copy(Application.ExeName, 1, Length(Application.ExeName)-4) +
  257.     'ini';
  258.   Reg := TIniFile.Create(FileName);
  259.   Try
  260.     Value := Reg.ReadString(CompanyName, 'Registered', '0');
  261.     if (Value = '1') then
  262.     begin
  263.       Registered := TRUE;
  264.       PriceLabel.Caption := 'Registered to ' + #13+#10 +
  265.         Reg.ReadString(CompanyName, 'Username', 'UnRegistered');
  266.       LeftImage.Visible := FALSE;
  267.       RightImage.Visible := FALSE;
  268.       PriceLabel.Left := LeftImage.Left;
  269.       PriceLabel.Width := RightImage.Left + RightImage.Width - LeftImage.Left;
  270.     end;
  271.   finally
  272.     Reg.Free;
  273.   end;
  274. end;
  275.  
  276.  
  277. end.
  278.  
  279.  
  280.