program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1};
{$R *.RES}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
//____________________________________________________________________
//Project File Above
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Panel1: TPanel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
procedure showMyMsg(Sender:TObject);
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
//Assume you will add a panel to a form and put a button on the panel
var
aForm:TForm;
aPanel:TPanel;
aButton:TButton;
begin
aForm:=Tform.create(application);
aForm.Top:=200;
aForm.Left:=200;
aForm.Width:=320;
aForm.Height:=200;
aForm.Caption:='this is a form generate by CODE';
{all other properties for this form can be specified Here}
aPanel:=TPanel.create(aForm);
aPanel.parent:=aForm;
aPanel.align:=alTop;
aPanel.caption:='';
{all other properties for this panel can specified Here}
aButton:=TButton.create(aForm);
aButton.parent:=aPanel;
aButton.caption:='click me';
aButton.OnClick:=showMyMsg;
aForm.ShowModal;
end;
procedure TForm1.showMyMsg(Sender: TObject);
begin
ShowMessage(Sender.ClassName+' is clicked at:'+DateTimeToStr(now) );
end;
end.
//____________________________________________________________________
//Unit file Above