Delphi XE MessageDlg[3] 返回判定与处理
//滔Roy 2022.09.30 procedure THeaderFooterForm.MDlgResult1(Sender: TObject;const AResult:TModalResult); begin if AResult=mrYes then ShowMessage('yes3') else if AResult=mrNo then ShowMessage('No3'); end; procedure THeaderFooterForm.Button3Click(Sender: TObject); begin {function MessageDlg(const AMessage: string; const ADialogType: TMsgDlgType; const AButtons: TMsgDlgButtons; const AHelpContext: THelpContext): Integer; } if MessageDlg('测试 mbYesNo返回1.', TMsgDlgType.mtInformation, [TMsgDlgBtn.mbYes, TMsgDlgBtn.mbNo], 0)=mrYes then begin MessageDlg('点击了yes1.', TMsgDlgType.mtInformation, [TMsgDlgBtn.mbOk], 0); end; {procedure MessageDlg(const AMessage: string; const ADialogType: TMsgDlgType; const AButtons: TMsgDlgButtons; const AHelpContext: THelpContext; const ACloseDialogProc: TInputCloseDialogProc);} MessageDlg('测试 mbYesNo返回2.', TMsgDlgType.mtInformation, [TMsgDlgBtn.mbYes, TMsgDlgBtn.mbNo], 0, procedure(const AResult:TModalResult) begin if AResult=mrYes then ShowMessage('yes2') else if AResult=mrNo then ShowMessage('No2'); end ); {procedure MessageDlg(const AMessage: string; const ADialogType: TMsgDlgType; const AButtons: TMsgDlgButtons; const AHelpContext: THelpContext; const ACloseDialogEvent: TInputCloseDialogEvent; const AContext: TObject);} //可以指定对象,以及触发指定对象中的方法 MessageDlg('测试 mbYesNo返回3.', TMsgDlgType.mtInformation, [TMsgDlgBtn.mbYes, TMsgDlgBtn.mbNo], 0,MDlgResult1,HeaderFooterForm); {function MessageDlg(const AMessage: string; const ADialogType: TMsgDlgType; const AButtons: TMsgDlgButtons; const AHelpContext: THelpContext; const ADefaultButton: TMsgDlgBtn): Integer;//默认按钮 } if MessageDlg('测试 mbYesNo返回4.', TMsgDlgType.mtInformation, [TMsgDlgBtn.mbYes, TMsgDlgBtn.mbNo], 0, TMsgDlgBtn.mbNo)=mrYes then begin MessageDlg('点击了yes4.', TMsgDlgType.mtInformation, [TMsgDlgBtn.mbOk], 0); end; {procedure MessageDlg(const AMessage: string; const ADialogType: TMsgDlgType; const AButtons: TMsgDlgButtons; const AHelpContext: THelpContext; const ADefaultButton: TMsgDlgBtn;const ACloseDialogProc: TInputCloseDialogProc);} //默认按钮+ ACloseDialogProc 事件 MessageDlg('测试 mbYesNo返回5.', TMsgDlgType.mtInformation, [TMsgDlgBtn.mbYes, TMsgDlgBtn.mbNo], 0, TMsgDlgBtn.mbNo, procedure(const AResult:TModalResult) begin if AResult=mrYes then ShowMessage('yes5') else if AResult=mrNo then ShowMessage('No5'); end ); {procedure MessageDlg(const AMessage: string; const ADialogType: TMsgDlgType; const AButtons: TMsgDlgButtons; const AHelpContext: THelpContext; const ADefaultButton: TMsgDlgBtn;const ACloseDialogEvent: TInputCloseDialogEvent; const AContext: TObject); } //只是在测试3的基础上加了默认按钮 MessageDlg('测试 mbYesNo返回6.', TMsgDlgType.mtInformation, [TMsgDlgBtn.mbYes, TMsgDlgBtn.mbNo], 0, TMsgDlgBtn.mbNo,MDlgResult1,HeaderFooterForm); { TInputCloseDialogProc = reference to procedure(const AResult: TModalResult); TInputCloseDialogEvent = procedure(Sender: TObject; const AResult: TModalResult) of object; } end;
创建时间:2022.09.30 更新时间: