Skip to content

Instantly share code, notes, and snippets.

@adnan360
Created November 12, 2016 14:33
Show Gist options
  • Save adnan360/ecd3ef975e09eef3952a152a27b351ac to your computer and use it in GitHub Desktop.
Save adnan360/ecd3ef975e09eef3952a152a27b351ac to your computer and use it in GitHub Desktop.
How to create an about form without having a form
procedure TfrmEditor.Closeme(Sender: TObject);
begin
tform( tcontrol(sender).parent ).Close;
end;
procedure TfrmEditor.mnuAboutClick(Sender: TObject);
const
margin = 20;
var
frm: TForm;
lbl: TLabel;
img: TImage;
btn: TButton;
begin
try
frm:=TForm.Create(frmEditor);
lbl:=TLabel.Create(frm);
img:=TImage.Create(frm);
btn:=TButton.Create(frm);
frm.Caption:='About Snapping Tool';
frm.Width:=300;
frm.Height:=200;
frm.BorderStyle:=bsSingle;
frm.Position:=poOwnerFormCenter;
// Image
//img.AutoSize:=true;
img.Picture.Icon:=Application.Icon;
img.Left:=margin;
img.Top:=margin;
img.SetBounds(margin,margin,32,32);
img.Parent:=frm;
img.Show;
// Label
lbl.AutoSize:=False;
lbl.Caption:='Snapping Tool is a screenshot utility'#13#10'made to be quick and simple';
lbl.SetBounds(margin+img.Width+margin,margin,frm.ClientWidth-(margin*2),frm.ClientHeight-(margin*2));
lbl.Parent:=frm;
lbl.Show;
// Button
btn.Caption:='Close';
btn.SetBounds(margin+img.Width,frm.ClientHeight-margin-25,150,25);
btn.Parent:=frm;
btn.Show;
btn.OnClick:=@Closeme;
frm.ShowModal;
finally
lbl.Free;
img.Free;
frm.Free;
end;
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment