1 if MessageDlg('即将退出,是否继续?', 2 mtConfirmation, [mbYes, mbNo], 0) = mrYes then 3 begin 4 Close; 5 end;
对话框类型:
mtwarning——含有感叹号的警告对话框
mterror——含有红色叉符号的错误对话框
mtinformation——含有蓝色i符号的信息对话框
mtconfirmation——含有绿色问号的确认对话框
mtcustom——不含图标的一般对话框,对话框的标题是程序的名称
按钮组中的按钮:
1 mbYes——mrYes或6 2 mbNo——mrNo或7 3 mbOk——mrOk或1 4 mbCancel——mrCancel或2 5 mbHelp——help按钮 6 mbAbort——mrAbort或3 7 mbRetry——mrRetry或4 8 mbIgnore——mrIgnore或5 9 mbAll——mrAll或8 10 mbNoToAll——9 11 mbYesToAll——10
1 procedure TForm1.Button1Click(Sender: TObject); 2 var 3 S:string; 4 begin 5 if MessageDlg('提示框',mtInformation,[mbok,mbyes],0)=mryes then 6 messagebeep(MB_ICONEXCLAMATION); 7 end; 8 TMsgDlgType = (mtWarning, mtError, mtInformation, mtConfirmation, mtCustom); 9 10 TMsgDlgBtn = (mbYes, mbNo, mbOK, mbCancel, mbAbort, mbRetry, mbIgnore, 11 mbAll, mbNoToAll, mbYesToAll, mbHelp); 12 const 13 mrNone = 0; 14 mrOk = idOk; 15 mrCancel = idCancel; 16 mrAbort = idAbort; 17 mrRetry = idRetry; 18 mrIgnore = idIgnore; 19 mrYes = idYes; 20 mrNo = idNo; 21 mrAll = mrNo + 1; 22 mrNoToAll = mrAll + 1; 23 mrYesToAll = mrNoToAll + 1;