Delphi 中使用Dialog API
2022-11-30 10:52:08 作者:admin
本文整理自网络,侵删。
Delphi / C ++ Builder 10.1 Belrin的新功能之一是“简化对话框API”。
使用的函数是InputQuery。
TDialogService.InputQuery关数TDialogService.InputQuery函数显示一个带有输入字段的对话框。
procedure TForm1.ButtonInputDialogClick(Sender: TObject);begin TDialogService.InputQuery( 'Input String', ['Enter Your Name'], ['Your Name'], procedure(const AResult: TModalResult; const AValues: array of string) begin Memo1.Lines.Add('Your Name = ' + AValues[0]); end); Memo1.Lines.Add('ButtonInputDialogClick');end;执行上述代码后,在Windows和OSX上显示对话框后,将输出“ ButtonInputDialogClick”。
取决于操作系统,此功能的行为似乎有所不同。
THE处理中视窗同期OSX同期安卓系统异步的的iOS异步的此外,TDialogService.InputQuery,你可以有多个输入字段。
procedure TForm1.ButtonInputDialogClick(Sender: TObject);begin TDialogService.InputQuery( 'Input String', ['Enter Your First Name', 'Enter Your Family Name'], ['First Name', 'Family Name'], procedure(const AResult: TModalResult; const AValues: array of string) begin Memo1.Lines.Add('First Name = ' + AValues[0]); Memo1.Lines.Add('Family Name = ' + AValues[1]); end); Memo1.Lines.Add('Button1Click');end;在iOS上,此代码导致运行时错误。看来您不能有多个输入字段。它适用于Windows,OSX和Android。
THE多个领域视窗○OSX○安卓系统○的iOS×IFMXDialogServiceSync.InputQuerySync关数IFMXDialogServiceSync.InputQuerySync函数将被阻止,直到关闭对话框。
procedure TForm1.ButtonIFMXDialogServiceSyncClick(Sender: TObject);var Service: IFMXDialogServiceSync; AValues: array of string;begin AValues := ['Your Name']; if TPlatformServices.Current.SupportsPlatformService(IFMXDialogServiceSync, IInterface(Service)) then begin if Service.InputQuerySync('Input String', ['Enter Your Name'], AValues) then begin Memo1.Lines.Add('Your Name = ' + AValues[0]); end; end; Memo1.Lines.Add('ButtonIFMXDialogServiceSyncClick');end;在Windows,OSX和iOS上,显示对话框后输出“ ButtonIFMXDialogServiceSyncClick”。在Android上,不显示对话框,仅输出“ ButtonIFMXDialogServiceSyncClick”。
THE函授视窗○OSX○安卓系统×的iOS○此功能在iOS上也不支持多个字段。
IFMXDialogServiceAsync.InputQueryAsync关数IFMXDialogServiceSync.InputQueryAsync函数将继续处理,而无需等待对话框关闭。
procedure TForm1.ButtonIFMXDialogServiceAsyncClick(Sender: TObject);var Service: IFMXDialogServiceAsync;begin if TPlatformServices.Current.SupportsPlatformService(IFMXDialogServiceAsync, IInterface(Service)) then begin Service.InputQueryAsync('Input String', ['Enter Your Name'], ['Your Name'], procedure(const AResult: TModalResult; const AValues: array of string) begin Memo1.Lines.Add('Your Name = ' + AValues[0]); end); end; Memo1.Lines.Add('ButtonIFMXDialogServiceAsyncClick');end;在Windows,OSX,Android和iOS上,在输出“ ButtonIFMXDialogServiceAsyncClick”之后显示一个对话框。
相关阅读 >>
Delphi远程注入dll方法
Delphi汉字简繁体转换代码
Delphi 极速字符串替换函数
Delphi中组件label、edit、tag、memo、richedit
Delphi中使用汇编(关于pos函数的问题)
Delphi纯api窗体程序
Delphi在文件结尾写入和读出数据
Delphi xe 7 mediaplayer 在安卓里放不出声音
Delphi readprocessmemory用法
Delphi10.3模拟读取百度网页,并读取相关头部信息
更多相关阅读请进入《Delphi》频道 >>
猜你喜欢
联络方式:
400-123-789
邮箱:xiachao@163.com
Q Q:12345678
微信公众号
微信二维码