On Friday, November 14, 2003 8:16 AM Lutfie Royan wrote:

>
> saya ingin tanya, gimana caranya load form secara dinamis.  rencananya
saya
> akan simpan nana2 form didatabase, dan aplikasi akan meload form tersebut
> berdasarkan nama2 yg ada didatabase.
>

Ini contohnya, jangan lupa registerkan/unregisterkan semua form yang mau
dibuat scr runtime itu di blok initialization dan finalization.

unit frmMainU;
....
....
implementation
....
....

function CreateFormByName(const AForm: string; AParent : TComponent ): TForm
var
  lIndex: integer;
  lFormClass: TFormClass;
  AFormName: string;
begin
    Result := nil;
    // Buang dulu Standard Prefix 'T' di awal nama form
    AFormName := Copy(AForm, 2, length(AForm)-1);
    // pastikan form itu blom dibuat sebelumnya
    if FormByName(AFormName) = nil then
    begin
        // cek form itu udah diregistrasikan atau belum..
        lFormClass := TFormClass(GetClass(AForm));
        if lFormClass <> nil then
            Result := TForm(lFormClass.Create(Application)) do;
    end;
end;

...
...

initialization
  RegisterClasses([
      TfrmViewEmpList,
      TfrmViewPayment,
      TfrmViewDraft
    ]);
finalization
  UnRegisterClasses([
      TfrmViewEmpList,
      TfrmViewPayment,
      TfrmViewDraft
    ]);

end.



Salam,

-Jaimy
--
``Always listen to experts.  They'll tell you what can't be done, and why.
Then do it.''
      -- Lazarus Long


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/i7folB/TM
---------------------------------------------------------------------~->

Berlangganan: [EMAIL PROTECTED]
Stop Berlangganan: [EMAIL PROTECTED]
Keluhan Milis(Unbouncing,spam,dll): [EMAIL PROTECTED] 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 


Kirim email ke