• Delphi XE MessageDlg[3] 返回判定与处理


    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  更新时间:

  • 相关阅读:
    Redis 学习(二十)服务器
    Redis 学习(十八)连接
    Redis学习(十七) 脚本
    Redis学习(十六)事务
    Redis学习(十四) 发布订阅
    python中如何使用requests模块下载文件并获取进度提示?
    Python实例获取mp3文件的tag信息
    python 视频处理,提取视频相关帧,读取Excel
    爬虫数据采集技术趋势-智能化解析
    Python中文转拼音代码(支持全拼和首字母缩写)
  • 原文地址:https://www.cnblogs.com/guorongtao/p/16743756.html
Copyright © 2020-2023  润新知