Hi guys, I need to create one dynamic form and I need to place one button and assign onclick event to that button,...
Hi guys, I need to create one dynamic form and I need to place one button and assign onclick event to that button, how to I assign that event in my coding.
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Buttons, Vcl.DBGrids, Data.DB,Bde.DBTables,
Vcl.grids;
function Dynamicform(OwnerFrom : TComponent;DetailName : string;parentcom : TWinControl):Boolean;
implementation
function Dynamicform(OwnerFrom : TComponent;DetailName : string;parentcom : TWinControl):Boolean;
var FDetailForm : TForm;
dButton : TBitBtn;
begin
with OwnerFrom do
begin
if not Assigned(TForm(OwnerFrom.FindComponent(DetailName))) then
begin
TForm.Create(OwnerFrom).Name := DetailName;
FDetailForm := TForm(OwnerFrom.FindComponent(DetailName));
with FDetailForm do
begin
Position := poOwnerFormCenter;
BorderIcons := [biSystemMenu];
Width := 400;
Height := 600;
TBitBtn.Create(FDetailForm).Name := 'BB'+DetailName;
dButton := TBitBtn(FindComponent('BB'+DetailName));
with dButton do
begin
Parent := FDetailForm;
Align := alBottom;
Caption := '&Okay';
//how can assign procedre
OnClick := FORMCLOSE(dButton);
//how can assign procedre
end;
FDetailForm.ShowModal;
end;
end;
end;
end;
end.
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Buttons, Vcl.DBGrids, Data.DB,Bde.DBTables,
Vcl.grids;
function Dynamicform(OwnerFrom : TComponent;DetailName : string;parentcom : TWinControl):Boolean;
implementation
function Dynamicform(OwnerFrom : TComponent;DetailName : string;parentcom : TWinControl):Boolean;
var FDetailForm : TForm;
dButton : TBitBtn;
begin
with OwnerFrom do
begin
if not Assigned(TForm(OwnerFrom.FindComponent(DetailName))) then
begin
TForm.Create(OwnerFrom).Name := DetailName;
FDetailForm := TForm(OwnerFrom.FindComponent(DetailName));
with FDetailForm do
begin
Position := poOwnerFormCenter;
BorderIcons := [biSystemMenu];
Width := 400;
Height := 600;
TBitBtn.Create(FDetailForm).Name := 'BB'+DetailName;
dButton := TBitBtn(FindComponent('BB'+DetailName));
with dButton do
begin
Parent := FDetailForm;
Align := alBottom;
Caption := '&Okay';
//how can assign procedre
OnClick := FORMCLOSE(dButton);
//how can assign procedre
end;
FDetailForm.ShowModal;
end;
end;
end;
end;
end.
Comments
Post a Comment