600) this.width = 600;">
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm2 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
function MessageDlgEx(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; FocusBtn, CloseBtn: TMsgDlgBtn; HelpCtx: Longint): Integer;
const
ModalResults: array[TMsgDlgBtn] of Integer = (mrYes, mrNo, mrOk, mrCancel, mrAbort, mrRetry, mrIgnore, mrAll, mrNoToAll, mrYesToAll, 0) ;
begin
with CreateMessageDialog(Msg, DlgType, Buttons, FocusBtn) do
try
HelpContext := HelpCtx;
Position := poScreenCenter;
Result := ShowModal;
//if there's a cancel button, ignore CloseBtn.
if (result = mrCancel) AND (NOT (mbCancel in Buttons)) then result := ModalResults[CloseBtn];
finally
Free;
end;
end;
procedure TForm2.Button1Click(Sender: TObject);
begin
if mrNo = MessageDlg('Destroy all data?', mtWarning, [mbYes, mbNo], -1, mbNo) then
Exit
else
begin
ShowMessage('destroy all files');
end;
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
if mrNo = MessageDlgEx('Destroy all data?'+ #13#10 + 'Don''t click the X button!',mtWarning,[mbYes, mbNo], mbNo, mbNo, -1) then
Exit
else
begin
ShowMessage('destroy all files - will not happen if [x] clicked');
end;
end;
end.