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

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//滔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  更新时间:

posted on   滔Roy  阅读(198)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报

导航

点击右上角即可分享
微信分享提示