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
|
function DefMessageDlg(const aCaption: string; const Msg: string; DlgType: TMsgDlgType;
Buttons: TMsgDlgButtons; DefButton: Integer; HelpCtx: Longint): Integer;
//Crée une fenêtre de dialogue en précisant le bouton actif.
//Exemple avec le bouton non par défaut
//if DefMessageDlg('Voulez-vous le supprimer ?', mtConfirmation, mbYesNoCancel, mrno, 0) ...
var
i: Integer;
btn: TButton;
begin
with CreateMessageDialog(Msg, DlgType, Buttons) do
try
Caption := aCaption;
HelpContext := HelpCtx;
for i := 0 to ComponentCount - 1 do
begin
if Components[i] is TButton then
begin
btn := TButton(Components[i]);
btn.default := btn.ModalResult = DefButton;
if btn.default then
ActiveControl := Btn;
end;
end;
Result := ShowModal;
finally
Free;
end;
end; |
Partager