Skip to content

Commit

Permalink
Add version info to about box
Browse files Browse the repository at this point in the history
  • Loading branch information
damieng committed Feb 13, 2023
1 parent b9350cc commit d96b0a0
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 98 deletions.
6 changes: 3 additions & 3 deletions Source/About.lfm
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@ object frmAbout: TfrmAbout
Width = 265
end
object lblVersion: TLabel
Left = 303
Left = 64
Height = 13
Top = 32
Width = 26
Alignment = taRightJustify
Width = 265
Anchors = [akTop, akRight]
AutoSize = False
Caption = '0.0.0'
ParentColor = False
end
Expand Down
211 changes: 118 additions & 93 deletions Source/About.pas
Original file line number Diff line number Diff line change
@@ -1,93 +1,118 @@
unit About;

{$MODE Delphi}

{
Disk Image Manager - About window
Copyright (c) Damien Guard. All rights reserved.
Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
}

interface

uses
LCLIntf, Forms, ExtCtrls, StdCtrls, Graphics;

type
TfrmAbout = class(TForm)
btnOK: TButton;
imgAppIcon: TImage;
lblTitle: TLabel;
bvLine: TBevel;
lblVersion: TLabel;
timFade: TTimer;
lblWeb: TLabel;
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure btnOKClick(Sender: TObject);
procedure lblWebClick(Sender: TObject);
procedure timFadeTimer(Sender: TObject);
end;

var
frmAbout: TfrmAbout;

implementation

uses
Main;

{$R *.lfm}

procedure TfrmAbout.FormCreate(Sender: TObject);
begin
Caption := 'About ' + Application.Title;
lblTitle.Caption := Application.Title;
lblVersion.Caption := 'Compiled: ' + {$I %DATE%} + ' ' + {$I %TIME%};
end;

procedure TfrmAbout.timFadeTimer(Sender: TObject);
begin
if (timFade.Tag > 0) then
if (frmAbout.AlphaBlendValue < 250) then
frmAbout.AlphaBlendValue := frmAbout.AlphaBlendValue + timFade.Tag
else
begin
timFade.Enabled := False;
frmAbout.AlphaBlendValue := 255;
end
else
if (frmAbout.AlphaBlendValue > 5) then
frmAbout.AlphaBlendValue := frmAbout.AlphaBlendValue + timFade.Tag
else
begin
timFade.Enabled := False;
frmAbout.AlphaBlendValue := 0;
Close;
end;
end;

procedure TfrmAbout.FormShow(Sender: TObject);
begin
frmAbout.Font := frmMain.Font;
frmAbout.AlphaBlendValue := 0;
lblVersion.Font.Color := clBtnShadow;
timFade.Tag := 4;
timFade.Enabled := True;
end;

procedure TfrmAbout.lblWebClick(Sender: TObject);
begin
OpenDocument(PChar(TLabel(Sender).Caption));
end;

procedure TfrmAbout.btnOKClick(Sender: TObject);
begin
timFade.Tag := -4;
timFade.Enabled := True;
end;

end.
unit About;

{$MODE Delphi}

{
Disk Image Manager - About window
Copyright (c) Damien Guard. All rights reserved.
Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
}

interface

uses
LCLIntf, Forms, ExtCtrls, StdCtrls, Graphics, SysUtils, ShellApi, Windows;

type
TfrmAbout = class(TForm)
btnOK: TButton;
imgAppIcon: TImage;
lblTitle: TLabel;
bvLine: TBevel;
lblVersion: TLabel;
timFade: TTimer;
lblWeb: TLabel;
function GetAppVersion: String;
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure btnOKClick(Sender: TObject);
procedure lblWebClick(Sender: TObject);
procedure timFadeTimer(Sender: TObject);
end;

var
frmAbout: TfrmAbout;


implementation

uses
Main;

{$R *.lfm}

function TfrmAbout.GetAppVersion: String;
var
Size, Size2: DWord;
Pt, Pt2: Pointer;
begin
Size := GetFileVersionInfoSize(PChar(ParamStr(0)),Size2);
if (Size > 0) then
begin
GetMem(Pt,Size);
try
GetFileVersionInfo(PChar(ParamStr(0)),0,Size,Pt);
VerQueryValue(Pt,'\',Pt2,Size2);
with TVSFixedFileInfo(Pt2^) do
begin
Result := Format('%d.%d.%d.%d', [HiWord(dwFileVersionMS),LoWord(dwFileVersionMS),
HiWord(dwFileVersionLS),LoWord(dwFileVersionLS)]);
end;
finally
FreeMem(Pt);
end;
end;
end;

procedure TfrmAbout.FormCreate(Sender: TObject);
begin
Caption := 'About ' + Application.Title;
lblTitle.Caption := Application.Title;
lblVersion.Caption := Format('%s build: %s compiled %s %s', [{$I %FPCTARGETOS%}, GetAppVersion, {$I %DATE%}, {$I %TIME%}]);
end;

procedure TfrmAbout.timFadeTimer(Sender: TObject);
begin
if (timFade.Tag > 0) then
if (frmAbout.AlphaBlendValue < 250) then
frmAbout.AlphaBlendValue := frmAbout.AlphaBlendValue + timFade.Tag
else
begin
timFade.Enabled := False;
frmAbout.AlphaBlendValue := 255;
end
else
if (frmAbout.AlphaBlendValue > 5) then
frmAbout.AlphaBlendValue := frmAbout.AlphaBlendValue + timFade.Tag
else
begin
timFade.Enabled := False;
frmAbout.AlphaBlendValue := 0;
Close;
end;
end;

procedure TfrmAbout.FormShow(Sender: TObject);
begin
frmAbout.Font := frmMain.Font;
frmAbout.AlphaBlendValue := 0;
lblVersion.Font.Color := clBtnShadow;
timFade.Tag := 4;
timFade.Enabled := True;
end;

procedure TfrmAbout.lblWebClick(Sender: TObject);
begin
OpenDocument(PChar(TLabel(Sender).Caption));
end;

procedure TfrmAbout.btnOKClick(Sender: TObject);
begin
timFade.Tag := -4;
timFade.Enabled := True;
end;

end.
4 changes: 2 additions & 2 deletions Source/DiskImageManager.lpi
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
<UseVersionInfo Value="True"/>
<AutoIncrementBuild Value="True"/>
<MajorVersionNr Value="2"/>
<MinorVersionNr Value="3"/>
<BuildNr Value="104"/>
<MinorVersionNr Value="4"/>
<BuildNr Value="105"/>
<StringTable CompanyName="Envy Technologies" InternalName="Disk Image Manager" LegalCopyright="Copyright 2002-2023 Damien Guard." OriginalFilename="DiskImageManager.exe" ProductName="Disk Image Manager"/>
</VersionInfo>
<BuildModes Count="2">
Expand Down
Binary file modified Source/DiskImageManager.res
Binary file not shown.

0 comments on commit d96b0a0

Please sign in to comment.