- 人气:
- 放大
- 缩小
- 二维码
- 赞赏
delphi 常用4种对话框
procedure ShowInfo(const Text, Title: string);
begin
MessageBox(0, PChar(Text), PChar(Title), MB_OK or MB_ICONINFORMATION);
end;
procedure ShowError(const Text: string; const Title: string = '');
begin
MessageBox(0, PChar(Text), PChar(Title), MB_OK or MB_ICONEXCLAMATION);
end;
function ShowWarning(const Text: string; const Title: string = ''): Boolean;
begin
Result := MessageBox(0, PChar(Text), PChar(Title), MB_YESNO or MB_ICONWARNING or MB_DEFBUTTON2) = IDYES;
end;
function ShowQuestion(const Text: string; const Title: string = ''): Boolean;
begin
Result := MessageBox(0, PChar(Text), PChar(Title), MB_YESNO or MB_ICONQUESTION) = IDYES;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowInfo('内容','标题');
ShowError('内容','标题');
if ShowWarning('内容','标题') then ShowMessage('yes');
if ShowQuestion('内容','标题') then ShowMessage('yes');
end;
end.