Re:Creating VC's on the fly?
Pieter A. Myburgh (piet...@iafrica.com) wrote:
: Hi!
:
: Is there any way to create visual components at run-time?
Try this (create a new blank form, and put a button on it, and then put this
code as your buttonclick method; you must add Buttons to your USES clause);
{//////////////////////////////////////////}
procedure TForm1.Button1Click(Sender: TObject);
Var
A:TForm;
B:TBitBtn;
begin
A:=Tform.Create(Application);
With A Do Begin
Try
B:=TBitBtn.Create(A);
B.Parent:=A;
B.Kind:=bkOK;
B.Left:=5;
B.Top:=5;
B:=TBitBtn.Create(A);
B.Parent:=A;
B.Kind:=bkCancel;
B.Left:=5;
B.Top:=10+B.height;
If ShowModal=idOK Then Label1.Caption:='OK' else
Label1.Caption:='Cancel';
Finally
Free;
End;
End;
end;
{//////////////////////////////////////////}
Dr. A{*word*73}la A. Olowofoyeku (The African Chief)
E-mail : la...@keele.ac.uk
Author of: Chief's Installer Pro 2.80 for Win16 and Win32:
winner of PC PLUS Magazine Gold Award (April 1995 U.K. edition)
ftp://ftp.demon.co.uk/pub/ibmpc/win3/apps/chief/pro/cinstp28.zip
ftp://ftp.cis.ksu.edu/pub/upload/cinstp28.zip
ftp://ftp.coast.net/SimTel/win3/install/cinstp28.zip