🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.delphi.winforms.controls.using
Article #464

Re: Assembly

#464
From: Stefanidis Dimitris
Date: Mon, 11 Oct 2004 15:48
86 lines
3293 bytes
I Have an Winform as TWinForm2 wich is in package Package2.dll in unit 
mywinformu.pas.It has an public procedure as Foo wich does domething like 
put given string into an editbox as :
So
  var
   a:Assembly;
   typ:System.Type;
   meth,:MethodInfo;
   MyForm:System.Object;
begin
   a := Assembly.LoadFrom('Package2.dll');
   typ := a.GetType('WinForm2.TWinForm2');
   meth := typ.GetMethod('Foo');
   MyForm := Activator.CreateInstance(typ)
   meth.Invoke(MyForm,['something'])
end;


everything works fine
Now i want to create an class function wich creates the instance of winform 
and writes the given string into editbox and shows modal the form.
After modal result returns an string (wich typed in same editbox as result)


So
In TWinForm2
public
class function Foo_Ex(aString:String):String;

implementation
class function TWinForm2.Foo_Ex(aString:String):String;
begin
  With Self.Create do  //Constructor declared as virtual
     begin
       If ShowDialog = System.Windows.Forms.DialogResult.Ok then
          Result = EditBox1.Text
       else
         Result := '';
        Free;
     end;
end;

Now on Caller projects :

  var
   a:Assembly;
   typ:System.Type;
   meth,:MethodInfo;
   MyForm:System.Object;
   aResult:String;
begin
   a := Assembly.LoadFrom('Package2.dll');
   typ := a.GetType('WinForm2.TWinForm2');
   meth := typ.GetMethod('Foo_Ex');
{
   MyForm := Activator.CreateInstance(typ) Why Use activator and create 
instance of  form ??? class function does'n creates instance ?????
  }
   aResult := meth.Invoke(nil,['something']).ToString;
  here i'm getting parameter count mismatch why ????????? What i'm doing 
wrong ????????

end;

Ufffff that's all :)

Thanks a lot for your time



"Marc Rohloff [TeamB]" <"on request"> wrote in message 
news:160pc6hq54s6u.dlg@marcrohloff.40tude.net...
> On Mon, 11 Oct 2004 14:16:31 +0300, Stefanidis Dimitris wrote:
>
>> How can i create WinForm via Reflection with
>> call to it's Class Procedure ?????
>
>> I don't want to use Activator.CreateInstance .......
> Why don't you want to use Activator.CreateInstance? You can work
> around it but you are just going to be duplicating it.
>
> What exactly are you trying to do?
>
> -- 
> Marc Rohloff [TeamB]
> marc rohloff at myrealbox dot com 
Technical Details
Message-ID: <416aab1c$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.frii.net!newsfeed.frii.net!news.compaq.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <416a6b58@newsgroups.borland.com> <160pc6hq54s6u.dlg@marcrohloff.40tude.net>

Show Full Headers
Complete Article Headers
X-Google-Thread: 1eff29,f1ab105b74fcb56e
X-Google-Attributes: gid1eff29,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Stefanidis Dimitris" <distef01@yahoo.gr>
Newsgroups: borland.public.delphi.winforms.controls.using
References: <416a6b58@newsgroups.borland.com> <160pc6hq54s6u.dlg@marcrohloff.40tude.net>
Subject: Re: Assembly
Date: Mon, 11 Oct 2004 18:48:36 +0300
Lines: 88
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 194.30.233.129
Message-ID: <416aab1c$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1097509660 194.30.233.129 (11 Oct 2004 08:47:40 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.frii.net!newsfeed.frii.net!news.compaq.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail