On Friday, November 14, 2003 4:00 PM herman wrote:
>
> Bung Jaimy bisa tolong perjelas fungsi contoh load form yg anda berikan
> sepertinya masih ada yg kurang
>
Maaf, memang contoh kode yang saya berikan sebelumnya itu ndak saya tes.
>
> atau kalo bisa bisa kasih contoh program kecil
> yg memanggil form dari database,
>
ini sample kode yang sudah saya tes beserta contoh penggunaannya. :-)
Salam,
-Jaimy
--
``Always listen to experts. They'll tell you what can't be done, and why.
Then do it.''
-- Lazarus Long
/********************************************************/
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.dfm}
{ Fungsi ini untuk meng-create sebuah form secara generik dengan
memanfaatkan RTTI (Runtime type information) }
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 AParent.FindComponent(AFormName) = nil then
begin
// cek form itu udah diregistrasikan atau belum..
lFormClass := TFormClass(GetClass(AForm));
if lFormClass <> nil then
Result := TForm(lFormClass.Create(AParent));
end;
end;
{ Fungsi berikut sebagai contoh untuk memanggil memanggil sebuah
form yang diinput oleh user melalui control edit1; }
procedure TForm1.Button1Click(Sender: TObject);
var
AForm: TForm;
begin
AForm := CreateFormByName(Edit1.Text,Self);
if AForm = nil then
raise Exception.Create('Form yang anda maksud itu ndak ada. :(');
with AForm do
try
ShowModal;
finally
Free;
end;
end;
initialization
RegisterClasses([
TForm2
]);
finalization
UnRegisterClasses([
TForm2
]);
end.
------------------------ 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/