1]UniGui的弹出信息MessageDlg的原型定义如下:
procedure MessageDlg(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; CallBack: TUniDialogCallBackAnonProc);
其中DlgType(对话框架的类型)
1、mtConfirmation
2、mtCustom
3、mtError
4、mtInformation
5、mtWarning
示例如下
procedure TMainForm.UniThemeButton1Click(Sender: TObject); begin
MessageDlg('This is a confirmation!', mtConfirmation, [mbOK],nil);
UniSession.AddJS('Ext.get("messagebox-1001_header-title-textEl").setText("确认")');
MessageDlg('This is information!', mtInformation, [mbOK],nil);
UniSession.AddJS('Ext.get("messagebox-1001_header-title-textEl").setText("信息")');
MessageDlg('This is a warning!', mtWarning, [mbOK],nil);
UniSession.AddJS('Ext.get("messagebox-1001_header-title-textEl").setText("警告")');
MessageDlg('This is an Error!', mtError, [mbOK],nil);
UniSession.AddJS('Ext.get("messagebox-1001_header-title-textEl").setText("错误")');
end;
最后一个参数的使用方法:
//mbYes,mbYesNo, mbYesNoCancel, mbOk ,mbOkCancel MessageDlg('是否?', mtConfirmation, mbYesNoCancel, procedure(Sender: TComponent; Res: Integer) begin Case Res of mrYes: // 点Yes后执行的语句 begin caption := 'mrYes' end; mrNo: // 点No后执行的语句 begin caption := 'mrNo' end; mrCancel: // 点Cancel后执行的语句 begin caption := 'Mrcancel' end; end; end);
更多信息参见官网说明:
2]类似地 Prompt获得数据//uniGUIDialogs.Prompt
procedure Prompt(const AMsg: string; const AValue: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; CallBack: TUniPromptCallBackAnonProc; MultiLines: Boolean = False); overload;
Prompt('Please enter a text', '默认输入值', mtInformation, mbOkCancel, procedure(Sender: TComponent; AResult: Integer; AText: string) begin Case AResult of mrOk: // 点Ok后执行的语句 begin caption := AText + 'Ok' end; mrCancel: // 点Cancel后执行的语句 begin caption := AText + 'Mrcancel' end; end; end, true // 是否多行 );
with UniSweetAlert1 do begin AlertType := TAlertType(UniComboBox1.ItemIndex); //设置提示类型 AllowEscapeKey := UniCheckBox1.Checked; //是否允许按ESC AllowOutsideClick := UniCheckBox2.Checked; //是否允许外部点击 CancelButtonText := UniEdit1.Text; //取消按钮的中文内容 ConfirmButtonText := UniEdit2.Text; //确认按钮的中文内容 ShowCancelButton := UniCheckBox3.Checked; //是否显示取消按钮 ShowCloseButton := UniCheckBox4.Checked; //是否显示关闭按钮 ShowLoaderOnConfirm := ShowLoader; //是否确认前等待 Title := UniEdit3.Text; //提示信息 // InputType := ItText; end; UniSweetAlert1.Show();