home *** CD-ROM | disk | FTP | other *** search
Wrap
unit Splash; {$I Misc.inc} {----------------------------------------------------------------------------- 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 http://www.mozilla.org/MPL/MPL-1.1.html 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. The Original Code is: Splash.pas, released 12 September 2000. The Initial Developer of the Original Code is Mat Ballard. Portions created by Mat Ballard are Copyright (C) 1999 Mat Ballard. Portions created by Microsoft are Copyright (C) 1998, 1999 Microsoft Corp. All Rights Reserved. Contributor(s): Mat Ballard e-mail: mat.ballard@chemware.hypermart.net. Last Modified: 05/25/2000 Current Version: 2.00 You may retrieve the latest version of this file from: http://Chemware.hypermart.net/ This work was created with the Project JEDI VCL guidelines: http://www.delphi-jedi.org/Jedi:VCLVCL in mind. Purpose: This file contains the SplashBox form. This form is used to display a standard "Splash" dialog box with a few extra wrinkles. Known Issues: -----------------------------------------------------------------------------} interface uses FileInfo, Classes, SysUtils, IniFiles, {$IFDEF WINDOWS} WinTypes, WinProcs, ShellAPI, Buttons, Controls, ExtCtrls, Forms, Graphics, StdCtrls, {$ENDIF} {$IFDEF WIN32} Windows, ShellAPI, Buttons, Controls, ExtCtrls, Forms, Graphics, StdCtrls, {$ENDIF} {$IFDEF LINUX} QTypes, QButtons, QControls, QExtCtrls, QForms, QGraphics, QStdCtrls, {$ENDIF} Misc; type TSplashBox = class(TForm) Panel1: TPanel; ProductLabel: TLabel; VersionLabel: TLabel; CopyrightLabel: TLabel; URLLabel: TLabel; CommentsLabel: TLabel; LeftImage: TImage; RightImage: TImage; PriceLabel: TLabel; AgreeBitBtn: TBitBtn; DisagreeBitBtn: TBitBtn; ViewLicenseBitBtn: TBitBtn; CompanyLabel: TLabel; Timer1: TTimer; procedure FormShow(Sender: TObject); procedure URLLabelClick(Sender: TObject); procedure OpenObject(sObjectPath : PChar); procedure ProgramIconClick(Sender: TObject); procedure ViewLicenseBitBtnClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure Timer1Timer(Sender: TObject); private Registered: Boolean; CompanyName: String; ProgramIcon: TImage; procedure GetRegistration; public {$IFNDEF LANG_ENGLISH} procedure DoCaptionsFromResource; {$ENDIF} procedure DoHintsFromResource; end; var SplashBox: TSplashBox; {This is the "Splash" dialog box that TSplashDlg displays when its Execute function is called.} {} {As well as the properties mentioned elsewhere, it also shows the free resources and operating system.} implementation {$R *.dfm} {------------------------------------------------------------------------------ Procedure: TSplashBox.FormCreate Description: standard FormCreate procedure Author: Mat Ballard Date created: 04/25/2000 Date modified: 04/25/2000 by Mat Ballard Purpose: sets the position and fills the labels Known Issues: ------------------------------------------------------------------------------} procedure TSplashBox.FormCreate(Sender: TObject); var Info: TFileVersionInfo; begin ProgramIcon := TImage.Create(Self); ProgramIcon.Parent := Panel1; ProgramIcon.Left := 8; ProgramIcon.Top := 8; ProgramIcon.AutoSize := TRUE; ProgramIcon.Picture.Bitmap.LoadFromResourceID(hInstance, 100); {$IFNDEF LANG_ENGLISH} DoCaptionsFromResource; {$ENDIF} DoHintsFromResource; {$IFDEF MSWINDOWS} //Self.PixelsPerInch := 96; Self.BorderStyle := bsDialog; {$ENDIF} {$IFDEF LINUX} //Self.PixelsPerInch := 75; Self.BorderStyle := fbsDialog; {$ENDIF} Left := Screen.Width - Self.Width div 2; Top := Screen.Height - Self.Height div 2; ClientHeight := AgreeBitBtn.Top + 3 * AgreeBitBtn.Height div 2; ClientWidth := Panel1.Left + Panel1.Width + Panel1.Left; AgreeBitBtn.Left := (Self.ClientWidth - AgreeBitBtn.Width) div 2; {get version information:} Info := TFileVersionInfo.Create(self); Info.ExecutableFile := Application.ExeName; ProductLabel.Caption := Info.ProductName; CompanyName := Info.CompanyName; CompanyLabel.Caption := sBy + Info.CompanyName; VersionLabel.Caption := sVersion + ' ' + Info.FileVersion; CopyrightLabel.Caption := Info.LegalCopyright; CommentsLabel.Caption := Info.Comments; Info.Free; GetRegistration; end; {------------------------------------------------------------------------------ Procedure: TSplashBox.DoCaptionsFromResource Description: standard loading of labels from resources Author: Mat Ballard Date created: 06/25/2001 Date modified: 06/25/2001 by Mat Ballard Purpose: display in different languages Known Issues: ------------------------------------------------------------------------------} {$IFNDEF LANG_ENGLISH} procedure TSplashBox.DoCaptionsFromResource; begin ViewLicenseBitBtn.Caption := sViewLicense; AgreeBitBtn.Caption := sIAgree; DisAgreeBitBtn.Caption := sIDisAgree; end; {$ENDIF} {------------------------------------------------------------------------------ Procedure: TSplashBox.DoHintsFromResource Description: standard loading of hints from resources Author: Mat Ballard Date created: 06/25/2001 Date modified: 06/25/2001 by Mat Ballard Purpose: display hints in different languages Known Issues: ------------------------------------------------------------------------------} procedure TSplashBox.DoHintsFromResource; begin URLLabel.Hint := sURLLabelHint; ProgramIcon.Hint := sProgramIconHint; ViewLicenseBitBtn.Hint := sViewLicenseBitBtnHint; AgreeBitBtn.Hint := sIAgreeBitBtnHint; end; {------------------------------------------------------------------------------ Procedure: TSplashBox.FormShow Description: standard FormShow event handler Author: Mat Ballard Date created: 04/25/2000 Date modified: 04/25/2000 by Mat Ballard Purpose: sets the Position on screen Known Issues: ------------------------------------------------------------------------------} procedure TSplashBox.FormShow(Sender: TObject); begin Left := (Screen.Width - Width) div 2; Top := (Screen.Height - Height) div 2; end; procedure TSplashBox.URLLabelClick(Sender: TObject); var TempString : array[0..255] of char; begin StrPCopy(TempString,URLLabel.Caption); OpenObject(TempString); end; procedure TSplashBox.OpenObject(sObjectPath : PChar); begin {$IFDEF WINDOWS} ShellExecute(0, Nil, sObjectPath, Nil, Nil, 3); {?SW_SHOW ?} {$ENDIF} {$IFDEF WIN32} ShellExecute(0, Nil, sObjectPath, Nil, Nil, SW_NORMAL); {$ENDIF} {$IFDEF LINUX} // {$ENDIF} end; procedure TSplashBox.ProgramIconClick(Sender: TObject); begin OpenObject('http://www.borland.com/delphi/'); end; procedure TSplashBox.ViewLicenseBitBtnClick(Sender: TObject); begin {$IFDEF MSWINDOWS} Application.HelpContext(HelpContext); //Application.HelpJump(HelpContext); {$ENDIF} end; procedure TSplashBox.Timer1Timer(Sender: TObject); begin ModalResult := mrOk; end; procedure TSplashBox.GetRegistration; var Reg: TIniFile; FileName: String; Value: String; begin FileName := Copy(Application.ExeName, 1, Length(Application.ExeName)-4) + 'ini'; Reg := TIniFile.Create(FileName); Try Value := Reg.ReadString(CompanyName, 'Registered', '0'); if (Value = '1') then begin Registered := TRUE; PriceLabel.Caption := 'Registered to ' + #13+#10 + Reg.ReadString(CompanyName, 'Username', 'UnRegistered'); LeftImage.Visible := FALSE; RightImage.Visible := FALSE; PriceLabel.Left := LeftImage.Left; PriceLabel.Width := RightImage.Left + RightImage.Width - LeftImage.Left; end; finally Reg.Free; end; end; end.