1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Donation with Paypal!!!

    Go to your paypal account and send directly donation to [email protected]

    1 month - 10 $ - Standart VIP

    6 months - 20 $- Standart VIP

    1 year - 30 $- Standart VIP

    2 years - 50 $- Standart VIP

    Gold member for life - 150 $- Standart VIP

    High Vip (Standart VIP include) group please send PM or email to [email protected] for info

    After Donation please send email to [email protected]

  3. Donation Ways 2020


    Paysend
  4. Telegram
Dismiss Notice

Donation with Paypal!!!

Go to your paypal account and send directly donation to [email protected]

1 month - 10 $ - Standart VIP

6 months - 20 $- Standart VIP

1 year - 30 $- Standart VIP

2 years - 50 $- Standart VIP

Gold member for life - 150 $- Standart VIP

High Vip (Standart VIP include) group please send PM or email to [email protected] for info

After Donation please send email to [email protected]

Dismiss Notice
For open hidden message no need write thanks, thank etc. Enough is click to like button on right side of thread.

Call forms in Delphi using Generics

Discussion in 'Delphi Programming' started by AdminDF, May 29, 2014.

  1. AdminDF
    Online

    AdminDFAdminDF is a Verified Member Delphifan Staff Member DF Staff

    What is Generics – http://docwiki.embarcadero.com/RADStudio/XE4/en/Overview_of_Generics

    Declaring class with static methods to create a form.

    Code:
    type
      TCallForms = class
        class procedure ShowModal();  overload; static;
        class procedure ShowModal( var pForm: F );  overload; static;
      end;
    Implementing generics functions to call form

    Code:
    class procedure TCallForms.ShowModal(var pForm: F);
    begin
      pForm := F( TFormClass(F).Create( nil ) );
      try
        pForm.ShowModal
      finally
        FreeAndNil(pForm);
      end;
    end;
    
    class procedure TCallForms.ShowModal();
    var
      Form: F;
    begin
      TCallForms.ShowModal(Form);
    end;
    How to use.
    Created and assigned variable global.

    1
    TCallForms.ShowModal<TForm1>(Form1);
    Created and not assigned varible.


    1
    TCallForms.ShowModal<TForm1>();
    The full source code. HERE
     

Share This Page