In many confirmation dialogs, it is useful to have this option (a quick way to disable confirmation). But I can not find how to do it. I do not want to develop it myself, because I need this dialogue to be standard and not want to redo it with every update of Delphi. Is there an easy way to use the standard Delphi confirmation dialog with this flag?
UPDATE2. The proposed SynTaskDialog library from the Synopse project does an excellent job (all I need and more), I will use it in my projects. Thanks!
UPDATE So thanks guys for the ideas. The MessageBoxCheck system function is a nice solution, but it doesn't seem to be as stable as it should be. In general, I agree that it is recommended to use the latest API functions to provide users with the best user interface of modern OS and use the old-fashioned design for older systems. At the moment, I remain on a simple solution (the code is the following), but if someone shares the user interface support code for a modern OS, it will be fine.
function MsgDlgWithCB(const Msg,Title,CBMsg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; DefaultButton: TMsgDlgBtn; var cbDontAskAnymore: TCheckBox): TForm; var i: integer; b: TButton; y: integer; begin Result := CreateMessageDialog(Msg, DlgType, Buttons, DefaultButton) ; Result.Position := poScreenCenter; cbDontAskAnymore := TCheckBox.Create(Result); cbDontAskAnymore.Caption := CBMsg; cbDontAskAnymore.Width := 130; y := -1; for i := 0 to result.ComponentCount-1 do if result.Components[i] is TButton then begin b := TButton(result.Components[i]); b.Left := b.Left + cbDontAskAnymore.Width + 16; Result.ClientWidth := Max(Result.ClientWidth, b.Left+b.Width+16); y := b.Top+b.Height-cbDontAskAnymore.Height; end; if y<0 then y := Result.ClientHeight - cbDontAskAnymore.height - 16; Result.Caption := Title; cbDontAskAnymore.Parent := Result; cbDontAskAnymore.Top := y; cbDontAskAnymore.Left := 8; end; function MessageDlgCheckbox(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; DefaultButton: TMsgDlgBtn; var cbDontAskAnymore: Boolean; const Title: string ='Confirmation'; const CBMsg: string = 'Don''t ask anymore'): integer; var f: TForm; c: TCheckbox; begin f := MsgDlgWithCB(Msg,Title,CBMsg,DlgType,Buttons,DefaultButton,c); try result := f.ShowModal; cbDontAskAnymore := c.Checked; finally f.free; end; end;
delphi dialog delphi-xe3 confirmation
Andrei Galatyn
source share