title: Execute a method from a form created by class reference (Delphi)
body: <p>I have a form (form2) and I implemented the following PUBLIC method:</p>
  
  <pre><code>function ShowInterface(i:integer):boolean;
  </code></pre>
  
  <p>This form is in a package that will be DYNAMIC LOADED. Now I want to instantiate this form (form2) and execute the method above.</p>
  
  <p>Important: I can't reference form2's unit in form1.</p>
  
  <p>I tryed this code, but it never finds "ShowInterface" pointer (returns nil).</p>
  
  <pre><code>procedure TfrmForm1.Button1Click(Sender: TObject);
  var
    PackageModule: HModule;
    AClass: TPersistentClass;
    ShowInterface: function (i:integer):boolean;
    frm: TCustomForm;
  begin
    PackageModule := LoadPackage('form2.bpl');
    if PackageModule &lt;&gt; 0 then
    begin
      AClass := GetClass('TfrmForm2');
      if AClass &lt;&gt; nil then // &lt;&lt;-- FINE!! IT FINDS OUT 'TfrmForm2' in 'form2.bpl')
      begin
        frm := TComponentClass(AClass).Create(Self) as TCustomForm;
        ShowInterface := frm.MethodAddress('ShowInterface'); // &lt;&lt;-- HERE!! ALLWAYS RETURNS "NIL"
        if @ShowInterface &lt;&gt; nil then
          ShowInterface(1);
        // but if I call frm.Show, it works fine. frm is "loaded"!!!
  
        frm.Free;
      end;
      DoUnloadPackage(PackageModule);
    end;
  end;
  </code></pre>
  
  <p>Thanks in advance.</p>