zoukankan      html  css  js  c++  java
  • FMXUI

    在 FMXUI 开源库,增加了 UI.Dialog 单元。此单元实现了跨平台的基础对话框组件。使用时引用 UI.Dialog 即可。如果需要自定义对话框的样式, 可以添加一个 TDialogStyleManager 组件在主窗体中。

    GIT:  https://github.com/yangyxd/FMXUI

    对话框效果演示图(默认样式,Windows平台):

    此 Demo 已经包含在源码库中,主要代码如下:

    复制代码
    uses
      UI.Dialog, UI.Async;
    
    { TFrmaeDialog }
    
    procedure TFrmaeDialog.ButtonView1Click(Sender: TObject);
    begin
      TDialogBuilder.Create(Self)
        .SetMessage('我是一个消息框。')
        .Show;
    end;
    
    procedure TFrmaeDialog.ButtonView2Click(Sender: TObject);
    begin
      TDialogBuilder.Create(Self)
        .SetMessage('我是一个消息框。这里显示消息内容')
        .SetNegativeButton('Negative',
          procedure (Dialog: IDialog; Which: Integer) begin
            Hint(Dialog.Builder.NegativeButtonText);
          end
        )
        .SetNeutralButton('Neutral',
          procedure (Dialog: IDialog; Which: Integer) begin
            Hint(Dialog.Builder.NeutralButtonText);
          end
        )
        .SetPositiveButton('Positive',
          procedure (Dialog: IDialog; Which: Integer) begin
            Hint(Dialog.Builder.PositiveButtonText);
          end
        )
        .Show;
    end;
    
    procedure TFrmaeDialog.ButtonView3Click(Sender: TObject);
    begin
      TDialogBuilder.Create(Self)
        .SetTitle('我是标题文本')
        .SetMessage('我是一个消息框。这里显示消息内容')
        .SetNegativeButton('Negative',
          procedure (Dialog: IDialog; Which: Integer) begin
            Hint(Dialog.Builder.NegativeButtonText);
          end
        )
        .SetPositiveButton('Positive',
          procedure (Dialog: IDialog; Which: Integer) begin
            Hint(Dialog.Builder.PositiveButtonText);
          end
        )
        .Show;
    end;
    
    procedure TFrmaeDialog.ButtonView4Click(Sender: TObject);
    begin
      TDialogBuilder.Create(Self)
        .SetTitle('我是标题文本')
        .SetItems(['列表项 - 1', '列表项 - 2', '列表项 - 3', '列表项 - 4', '列表项 - 5'],
          procedure (Dialog: IDialog; Which: Integer) begin
            Hint(Dialog.Builder.ItemArray[Which]);
          end
        )
        .Show;
    end;
    
    procedure TFrmaeDialog.ButtonView5Click(Sender: TObject);
    begin
      TDialogBuilder.Create(Self)
        .SetTitle('我是标题文本')
        .SetSingleChoiceItems(['列表项 - 1', '列表项 - 2', '列表项 - 3', '列表项 - 4', '列表项 - 5'], 1)
        .SetPositiveButton('取消')
        .SetNegativeButton('确定',
          procedure (Dialog: IDialog; Which: Integer) begin
            Hint('选择了: ' + Dialog.Builder.ItemArray[Dialog.Builder.CheckedItem]);
          end
        )
        .Show;
    end;
    
    procedure TFrmaeDialog.ButtonView6Click(Sender: TObject);
    begin
      TDialogBuilder.Create(Self)
        .SetTitle('我是标题文本')
        .SetMultiChoiceItems(['列表项 - 1', '列表项 - 2', '列表项 - 3', '列表项 - 4', '列表项 - 5'], [])
        .SetPositiveButton('取消')
        .SetNegativeButton('确定',
          procedure (Dialog: IDialog; Which: Integer) begin
            Hint(Format('选择了 %d 项.', [Dialog.Builder.CheckedCount]));
          end
        )
        .Show;
    end;
    
    procedure TFrmaeDialog.ButtonView7Click(Sender: TObject);
    begin
      ShowWaitDialog('正在执行任务...', False);
      TAsync.Create()
      .SetExecute(
        procedure (Async: TAsync) begin
          Sleep(3000);
        end
      )
      .SetExecuteComplete(
        procedure (Async: TAsync) begin
          HideWaitDialog;
        end
      ).Start;
    end;
    
    procedure TFrmaeDialog.ButtonView8Click(Sender: TObject);
    begin
      ShowWaitDialog('正在执行任务...',
        procedure (Dialog: IDialog) begin
          Hint('任务被取消');
        end
      );
      TAsync.Create()
      .SetExecute(
        procedure (Async: TAsync) begin
          Sleep(5000);
        end
      )
      .SetExecuteComplete(
        procedure (Async: TAsync) begin
          if not IsWaitDismiss then // 如果任务没有被中断
            Hint('任务执行完成.');
          HideWaitDialog;
        end
      ).Start;
    end;
    
    procedure TFrmaeDialog.DoShow;
    begin
      inherited;
      tvTitle.Text := Title;
    end;
    
    procedure TFrmaeDialog.SpeedButton1Click(Sender: TObject);
    begin
      Finish;
    end;
    复制代码

    http://www.cnblogs.com/yangyxd/articles/5877638.html

  • 相关阅读:
    【2020省选Day1T1】LOJ3299 「联合省选 2020 A | B」冰火战士
    题解 CF1369 D,E,F Codeforces Round #652 (Div. 2)
    题解 LOJ3298 「BJOI2020」封印(SAM,数据结构)
    题解 nflsoj99 牛顿的烈焰激光剑(容斥,DP,数学)
    判断长度为3的等差数列(经典问题)
    树形图求和:一道经典矩阵知识题
    题解 LOJ2390 「JOISC 2017 Day 1」开荒者
    istio sidecar自动注入过程分析
    filebeat-kafka日志收集
    istio路由配置
  • 原文地址:https://www.cnblogs.com/findumars/p/5180882.html
Copyright © 2011-2022 走看看