FMXUI - UI.Dialog 示例(比较漂亮)
2024-08-31 21:33:22
在 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
最新文章
- Autodesk 最新开发技术研讨会 -8月22日-Autodesk北京办公室
- winform插件机制学习
- 一.	HTML认识
- python---str
- elk+redis分布式分析nginx日志
- requestFileSystem is undefined
- C#_数据库交互_SqlHelper
- bzoj1148
- 安装weblogic的步骤10.3.0.0
- FileSystemXmlApplicationContext方法的绝对路径问题
- Eclipse简介和使用技巧快捷方式
- Linux IPC实践(4) --System V消息队列(1)
- js术语扫盲贴:XHR、RegExp、call-apply、prototype
- 设计模式のMementoPattern(备忘录模式)----行为模式
- bash 文件名操作 常用方法
- tomcat 报错处理
- swoole 基础知识
- jsonp跨域设置cookie
- 【javascript】js 获取 url 后的参数值
- WireShark学习
热门文章
- Spring Boot初步认识
- 3、linux下Socket编程-TCP/UDP
- 洛谷 P3871 中位数
- Bootstrap相关优质项目必备网址
- [D3] Create Labels from Non-numeric Data with Ordinal Scales in D3 v4
- iOS开发runtime学习:一:runtime简介与runtime的消息机制
- ECharts.js 超简单入门(本质canvas)
- [React Router v4] Render Catch-All Routes with the Switch Component
- Redis数据存储解决方案
- Oracle数据库零散知识06 -- Package的定义与简单触发器