How to show a dialog box with two buttons (Continue / Close) in Delphi

I want to create a warning dialog box that asks users if the information entered during registration was correct and asks him if he wants to continue or close this dialog and correct his information.

+6
source share
4 answers
var td: TTaskDialog; tb: TTaskDialogBaseButtonItem; begin td := TTaskDialog.Create(nil); try td.Caption := 'Warning'; td.Text := 'Continue or Close?'; td.MainIcon := tdiWarning; td.CommonButtons := []; tb := td.Buttons.Add; tb.Caption := 'Continue'; tb.ModalResult := 100; tb := td.Buttons.Add; tb.Caption := 'Close'; tb.ModalResult := 101; td.Execute; if td.ModalResult = 100 then ShowMessage('Continue') else if td.ModalResult = 101 then ShowMessage('Close'); finally td.Free; end; end; 

enter image description here

Note: This will only work on Windows Vista or later .

+11
source
 var AMsgDialog: TForm; abutton: TButton; bbutton: TButton; begin AMsgDialog := CreateMessageDialog('This is a test message.', mtWarning,[]); abutton := TButton.Create(AMsgDialog); bbutton := TButton.Create(AMsgDialog); with AMsgDialog do try Caption := 'Dialog Title' ; Height := 140; AMsgDialog.Width := 260 ; with abutton do begin Parent := AMsgDialog; Caption := 'Continue'; Top := 67; Left := 60; // OnClick :tnotyfievent ; end; with bbutton do begin Parent := AMsgDialog; Caption := 'Close'; Top := 67; Left := 140; //OnClick :tnotyfievent ; end; ShowModal ; finally abutton.Free; bbutton.Free; Free; end; 

enter image description here

+8
source

if delphi then

 if mrYes=MessageDlg('Continue?',mtwarning,[mbYes, mbNo],0) then begin //do somthing end else exit; //go out 
+7
source

Based on this :

 procedure HookResourceString(rs: PResStringRec; newStr: PChar); var oldprotect: DWORD; begin VirtualProtect(rs, SizeOf(rs^), PAGE_EXECUTE_READWRITE, @oldProtect); rs^.Identifier := Integer(newStr); VirtualProtect(rs, SizeOf(rs^), oldProtect, @oldProtect); end; const SContinue = 'Continue'; SClose = 'Close'; procedure TForm1.Button1Click(Sender: TObject); begin HookResourceString(@SMsgDlgOK, SContinue); HookResourceString(@SMsgDlgCancel, SClose); if MessageDlg('My Message', mtConfirmation, [mbOK, mbCancel], 0) = mrOK then begin // OK... end; end; 
+2
source

Source: https://habr.com/ru/post/904310/


All Articles