title: Calling class functions of different forms
body: <p>I have an application which includes the "main" form as well as four other forms (formA, formB, formC, formD). Each one of the four forms has a unique <code>class function execute()</code>.</p>
  
  <p>Now, in formD, I put an edit box and a button. On the button's <code>OnClick</code> event, depending on which form's name I pass in the edit box, I want to run the appropriate class function.</p>
  
  <p>I tried to implement this task by creating a <code>TDictionary</code> in which I add 3 pairs of values, but it didn't work.  Specifically I did the following:</p>
  
  <pre><code>unit FormDU;
  
  interface
  
  type
    TFormD = class(TForm)
    Edit1: TEdit;
    fcShapeBtn1: TfcShapeBtn;
    .............
    .............
  public
    class function execute:boolean;
    ..........
    ..........
  end;
  
  var
    FormD: TFormD;
    MyList:TDictionary&lt;string,TForm&gt;;
  
  
  implementation 
  
  class function TFormD.execute:boolean;
    begin
      FormD:= TFormD.Create(nil);
      MyList:= TDictionary&lt;string,TForm&gt;.create;
      MyList.Add('FormA',TFormA);
      MyList.Add('FormB',TFormB);
      MyList.Add('FormC',TFormC);
      FormD.showmodal;
    end;
  
  procedure TFormD.fcShapeBtn1Click(Sender: TObject); 
  begin
    // Here I check whether the text in Edit1 box has the value of one of the
    // keys that are included in the MyList dictionary and if yes I want to 
    // trigger the class function execute of the appropriate form...
  
    if MyList.ContainsKey(Edit1.text) then  // suppose that text= formA
        MyList.Items[Edit1.text].execute // which doesn't work.... 
  
    // I thought that the 'Items' method of the dictionary would return back 
    // to me the appropriate form type - which is connected to the specific 
    // key - and thus I could call each form's class function execute()
  end;
  </code></pre>
  
  <p>I don't know how to solve this problem.</p>