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);
更多信息参见官网说明:
类似地 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, mbYesNoCancel, procedure (Sender: TComponent; AResult:Integer; AText: string) begin Case AResult of mrYes: // 点Ok后执行的语句 begin caption := AText+'yes' end; mrNo: // 点No后执行的语句 begin caption := AText+'mrNo' end; mrCancel: // 点Cancel后执行的语句 begin caption := AText+'Mrcancel' end; end; end ,true// 是否多行 );