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.

DelphiFan.FMX Dialog Unit

Discussion in 'Delphi Programming' started by AdminDF, Jun 3, 2015.

  1. AdminDF
    Online

    AdminDFAdminDF is a Verified Member Delphifan Staff Member DF Staff

    This thread is for FMX only units for use to anyone on the forum. Novices as well as old-timers can chip in or not. Any additions/modifications/deletions to any existing units on the thread I'll update this first post to include those changes and/or new units. Only one criteria should be in order and can change as time (or the moderators allow) and this should be:

    Only use the full namespace naming convention for units and the its use in the code. The reasoning behind this is so there will be no possible conflict between any possible units that may be in a project.

    For example:
    - All unit names should start with DelphFan and break out from there. Like the first unit I'm submitting is DelphiFan.FMX.CustomDialogs.
    - Inside of each procedure/function a procedure/function call should have the full namespace included. Like System.SysUtils.Trim() instead of just Trim()
    - Same goes for any types being used. Like System.UITypes.TMsgDlgBtn.mbOK instead of just mbOK.

    So to start off something simple and basic:
    DelphFan.FMX.CustomDialogs

    Code:
    unit DelphiFan.FMX.CustomDialogs;
    
    { -==
      The purpose of this unit is to be a placeholder for constantly used
      simple dialogs without having to constantly retype the same things over
      and over again.
    
      Due to the use of namespaces this unit should not conflict with any other unit
      ==-}
    
    interface
    
    uses
      System.SysUtils,
      System.UITypes,
      FMX.Dialogs,
      FMX.Forms;
    
      function CustomDialog(
            const aMsg : String = '';
            const aDlgType : System.UITypes.TMsgDlgType = System.UITypes.TMsgDlgType.mtCustom;
            const aButtons : System.UITypes.TMsgDlgButtons = [System.UITypes.TMsgDlgBtn.mbOK];
            const aDefaultButton : System.UITypes.TMsgDlgBtn = System.UITypes.TMsgDlgBtn.mbOK
            ) : System.UITypes.TModalResult;
    
      procedure FatalErrorDlg(const aCustomMsg : String = '');
    
      procedure InfoDlg(const aCustomMsg : String = '');
    
      procedure NotAllowedDlg(const aCustomMsg : String = '');
    
      function OkToExitDlg(const aCustomMsg : String = '') : Boolean;
    
      function YesNoDlg(const aCustomMsg : String = '') : Integer;
      function YesNoCancelDlg(const aCustomMsg : String = '') : Integer;
    
    implementation
    
    function CustomDialog(
          const aMsg : String = '';
          const aDlgType : System.UITypes.TMsgDlgType = System.UITypes.TMsgDlgType.mtCustom;
          const aButtons : System.UITypes.TMsgDlgButtons = [System.UITypes.TMsgDlgBtn.mbOK];
          const aDefaultButton : System.UITypes.TMsgDlgBtn = System.UITypes.TMsgDlgBtn.mbOK
          ) : System.UITypes.TModalResult; overload;
    var
      frmDialog : TForm;
    begin
      frmDialog := FMX.Dialogs.CreateMessageDialog(aMsg, aDlgType, aButtons, aDefaultButton);
      try
        frmDialog.ShowModal;
        Result := frmDialog.ModalResult;
      finally
        System.SysUtils.FreeAndNil(frmDialog);
      end;
    end;
    
    procedure FatalErrorDlg(const aCustomMsg : String = '');
    var
      sTmp : String;
    begin
      // set a default in case a msg wasn't passed
      sTmp := 'Fatal Error';
      if System.SysUtils.Trim(aCustomMsg) <> '' then
        sTmp := aCustomMsg;
    
      DelphiFan.FMX.CustomDialogs.CustomDialog(sTmp,
                   System.UITypes.TMsgDlgType.mtError,
                   [System.UITypes.TMsgDlgBtn.mbOK],
                   System.UITypes.TMsgDlgBtn.mbOK
                   );
    end;
    
    
    procedure InfoDlg(const aCustomMsg : String = '');
    begin
      DelphiFan.FMX.CustomDialogs.CustomDialog(aCustomMsg,
                   System.UITypes.TMsgDlgType.mtInformation,
                   [System.UITypes.TMsgDlgBtn.mbOK],
                   System.UITypes.TMsgDlgBtn.mbOK
                   );
    end;
    
    procedure NotAllowedDlg(const aCustomMsg : String = '');
    var
      sTmp : String;
    begin
      // set a default in case a msg wasn't passed
      sTmp := 'Action Not Allowed.';
      if System.SysUtils.Trim(aCustomMsg) <> '' then
        sTmp := aCustomMsg;
    
      DelphiFan.FMX.CustomDialogs.CustomDialog(sTmp, System.UITypes.TMsgDlgType.mtWarning, [System.UITypes.TMsgDlgBtn.mbOK], System.UITypes.TMsgDlgBtn.mbOK);
    end;
    
    function OkToExitDlg(const aCustomMsg  : String = '') : Boolean;
    var
      sMsg : String;
    begin
      // set a default in case a msg wasn't passed
      sMsg := 'Are you sure you wish to exit?';
      if System.SysUtils.Trim(aCustomMsg) <> '' then
        sMsg := aCustomMsg;
    
      Result := (DelphiFan.FMX.CustomDialogs.YesNoCancelDlg(sMsg) = mrYes);
    end;
    
    function YesNoDlg(const aCustomMsg : String = '') : Integer;
    begin
      Result := DelphiFan.FMX.CustomDialogs.CustomDialog(aCustomMsg,
                             System.UITypes.TMsgDlgType.mtConfirmation,
                             mbYesNo,
                             System.UITypes.TMsgDlgBtn.mbNo
                             );
    end;
    
    function YesNoCancelDlg(const aCustomMsg : String = '') : Integer;
    begin
      Result := DelphiFan.FMX.CustomDialogs.CustomDialog(aCustomMsg,
                             System.UITypes.TMsgDlgType.mtConfirmation,
                             FMX.Dialogs.mbYesNoCancel,
                             System.UITypes.TMsgDlgBtn.mbNo
                             );
    end;
    
    end.
     
  2. realist
    Online

    realistrealist is a Verified Member Administrator General Staff Member DF Staff

    RE:

    Thanks
     
  3. kami
    Offline

    kami DF Member

    Wow!
    Cool, thanks
     
  4. kkachura1973
    Offline

    kkachura1973 DF Member

    RE:

    Good Work
     
  5. carmas1234
    Offline

    carmas1234 DF Member

    Very good
     
  6. yeyoveloz
    Offline

    yeyoveloz DF Member

    RE:

    well done
     

Share This Page