unit uMain;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, ExtCtrls, ExtDlgs, StdCtrls;
type
TfrmMain =
class(TForm)
btnGo: TButton;
procedure btnGoClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
FFileA, FFileB:
string;
FFormA, FFormB: TForm;
FImageA, FImageB: TImage;
FTrackBarA, FTrackBarB: TTrackBar;
function GetImageFilename:
string;
procedure TrackBarAChange(Sender: TObject);
procedure TrackBarBChange(Sender: TObject);
public
{ Public declarations }
end;
var
frmMain: TfrmMain;
implementation
{$R *.dfm}
procedure TfrmMain.FormCreate(Sender: TObject);
begin
FFormA := TForm.Create(Self);
try
FFormA.Parent := Self.Parent;
FFormA.Height := 800;
FFormA.Width := 800;
FFormA.Position := poScreenCenter;
FFormA.BorderStyle := bsDialog;
FFormA.AlphaBlend := True;
FFormA.Visible := False;
FImageA := TImage.Create(FFormA);
try
FImageA.Parent := FFormA;
FImageA.Align := alClient;
FImageA.Stretch := True;
FTrackBarA := TTrackBar.Create(FFormA);
try
FTrackBarA.Parent := FFormA;
FTrackBarA.Align := alBottom;
FTrackBarA.Min := 0;
FTrackBarA.Max := 255;
FTrackBarA.Position := 255;
FTrackBarA.OnChange := TrackBarAChange;
finally
// FTrackBarA.Free;
end;
finally
// FImageA.Free;
end;
finally
// FFormA.Free;
end;
FFormB := TForm.Create(Self);
try
FFormB.Parent := Self.Parent;
FFormB.Height := 800;
FFormB.Width := 800;
FFormB.Position := poScreenCenter;
FFormB.BorderStyle := bsDialog;
FFormB.AlphaBlend := True;
FFormB.Visible := False;
FImageB := TImage.Create(FFormB);
try
FImageB.Parent := FFormB;
FImageB.Align := alClient;
FImageB.Stretch := True;
FTrackBarB := TTrackBar.Create(FFormB);
try
FTrackBarB.Parent := FFormB;
FTrackBarB.Align := alBottom;
FTrackBarB.Min := 0;
FTrackBarB.Max := 255;
FTrackBarB.Position := 255;
FTrackBarB.OnChange := TrackBarBChange;
finally
// FTrackBarB.Free;
end;
finally
// FImageB.Free;
end;
finally
// FFormB.Free;
end;
end;
procedure TfrmMain.FormDestroy(Sender: TObject);
begin
FTrackBarB.Free;
FImageB.Free;
FFormB.Free;
FTrackBarA.Free;
FImageA.Free;
FFormA.Free;
end;
procedure TfrmMain.TrackBarAChange(Sender: TObject);
begin
FFormA.AlphaBlendValue := (Sender
As TTrackBar).Position;
end;
procedure TfrmMain.TrackBarBChange(Sender: TObject);
begin
FFormB.AlphaBlendValue := (Sender
As TTrackBar).Position;
end;
function TfrmMain.GetImageFilename:
string;
var
dlg: TOpenPictureDialog;
begin
Result := '
';
dlg := TOpenPictureDialog.Create(Self);
try
dlg.Options := [ofPathMustExist, ofFileMustExist, ofDontAddToRecent, ofForceShowHidden];
if dlg.Execute(Self.Handle)
then
Result := dlg.FileName;
finally
dlg.Free;
end;
end;
procedure TfrmMain.btnGoClick(Sender: TObject);
begin
FFileA := GetImageFilename;
if FFileA = '
'
then
Exit;
FFileB := GetImageFilename;
if FFileB = '
'
then
Exit;
FFormA.Caption := FFileA;
try
FImageA.Picture.LoadFromFile(FFileA);
except
Exit;
end;
FFormB.Caption := FFileB;
try
FImageB.Picture.LoadFromFile(FFileB);
except
Exit;
end;
FFormA.Position := poScreenCenter;
FFormB.Position := poScreenCenter;
FFormA.Visible := True;
FFormB.Visible := True;
end;
end.