procedure TForm1.Button1Click(Sender: TObject); begin MessageBox(Handle, '这是一个警告', '警告', MB_ICONWARNING); end;
To display an icon in the message box, specify one of the following values. Value Meaning MB_ICONEXCLAMATION, MB_ICONWARNING An exclamation-point icon appears in the message box. MB_ICONINFORMATION, MB_ICONASTERISK An icon consisting of a lowercase letter i in a circle appears in the message box. MB_ICONQUESTION A question- icon appears in the message box. MB_ICONSTOP, MB_ICONERROR, MB_ICONHAND A stop-sign icon appears in the message box.
function MessageDlg(Const Msg:String;AType:TMsgDlgType;AButtons:TMsgDlgButtons;HelpCtx:Longint):Word; Msg参数:显示内容、 AType参数:决定消息框的类型,有mtInformation,mtError,mtWarning,mtConfirmaton. AButton参数:mbYes,mbNo,mbOK,mbCancel HelpCtx参数:帮助文件
Application.MessageBox('Text' ,'Caption' ,MB_ICONQUESTION)// ?
Application.MessageBox('Text' ,'Caption' ,MB_ICONERROR) //x
当然,需调用上面的函数。
begin
MessageBox(Handle, '这是一个警告', '警告', MB_ICONWARNING);
end;
MB_ICONEXCLAMATION,
MB_ICONWARNING An exclamation-point icon appears in the message box.
MB_ICONINFORMATION, MB_ICONASTERISK An icon consisting of a lowercase letter i in a circle appears in the message box.
MB_ICONQUESTION A question- icon appears in the message box.
MB_ICONSTOP,
MB_ICONERROR,
MB_ICONHAND A stop-sign icon appears in the message box.
Msg参数:显示内容、
AType参数:决定消息框的类型,有mtInformation,mtError,mtWarning,mtConfirmaton.
AButton参数:mbYes,mbNo,mbOK,mbCancel
HelpCtx参数:帮助文件
1.按钮
2.图标
3.默认按钮:
如:
Application.MessageBox('确认','你确认要册删除吗?',MB_YESNO+MB_ICONQUESTION+MB_DEFBUTTON2); 第一个数可取
MB_OK = $00000000;
MB_OKCANCEL = $00000001;
MB_ABORTRETRYIGNORE = $00000002;
MB_YESNOCANCEL = $00000003;
MB_YESNO = $00000004;
MB_RETRYCANCEL = $00000005;
第二个数可取
MB_ICONHAND = $00000010;
MB_ICONQUESTION = $00000020;
MB_ICONEXCLAMATION = $00000030;
MB_ICONASTERISK = $00000040;
MB_USERICON = $00000080;
MB_ICONWARNING = MB_ICONEXCLAMATION;
MB_ICONERROR = MB_ICONHAND;
MB_ICONINFORMATION = MB_ICONASTERISK;
MB_ICONSTOP = MB_ICONHAND;第三个数可取
MB_DEFBUTTON1 = $00000000;
MB_DEFBUTTON2 = $00000100;
MB_DEFBUTTON3 = $00000200;
MB_DEFBUTTON4 = $00000300;
MB_ICONINFORMATION
MB_ICONQUESTION
MB_ICONERROR
Application.MessageBox的按钮文字是中文的