Halaman

Selasa, 16 Agustus 2011

Delphi : Dynamic object creation, Class Reference

A quick note for those delphi developer needs to use the dynamic object creation :
using the class reference is the good way to do it :)

a simple example :
procedure TForm1.Button1Click(Sender: TObject);
type
  CRForm = class of TForm;
var
  a: array[0..2] of CRForm;
  c: TForm;
begin
  a[0] := TForm2;
  a[1] := TForm3;
  a[2] := TForm4;

  c := TForm(a[2].Create(self));

  c.ShowModal;

  c.Free;
end;           
welcome to the power! :)
hope you could utilize this technique on your next application development adventure!

Tidak ada komentar:

Posting Komentar