1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291 |
- unit IDE.MsgBoxDesignerForm;
- {
- Inno Setup
- Copyright (C) 1997-2024 Jordan Russell
- Portions by Martijn Laan
- For conditions of distribution and use, see LICENSE.TXT.
- MessageBox Designer form
-
- Originally contributed by leserg73
- }
- interface
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- UIStateForm, StdCtrls, ExtCtrls, NewStaticText, ComCtrls, pngimage;
- type
- TMsgBoxDesignerForm = class(TUIStateForm)
- IMGmbInformation: TImage;
- IMGmbConfirmation: TImage;
- IMGmbError: TImage;
- IMGmbCriticalError: TImage;
- Panel1: TPanel;
- GroupBox1: TGroupBox;
- GroupBox2: TGroupBox;
- MSGText: TMemo;
- rb_mbInformation: TRadioButton;
- rb_mbConfirmation: TRadioButton;
- rb_mbError: TRadioButton;
- rb_mbCriticalError: TRadioButton;
- GroupBox3: TGroupBox;
- MBDButtonOK: TButton;
- MBDButtonCancel: TButton;
- MBDButtonPreview: TButton;
- Bevel1: TBevel;
- rbMB_OK: TRadioButton;
- rbMB_OKCANCEL: TRadioButton;
- rbMB_YESNO: TRadioButton;
- rbMB_YESNOCANCEL: TRadioButton;
- rbMB_RETRYCANCEL: TRadioButton;
- rbMB_ABORTRETRYIGNORE: TRadioButton;
- GroupBox4: TGroupBox;
- cb_IDOK: TCheckBox;
- cb_IDCANCEL: TCheckBox;
- cb_IDYES: TCheckBox;
- cb_IDNO: TCheckBox;
- cb_IDABORT: TCheckBox;
- cb_IDRETRY: TCheckBox;
- cb_IDIGNORE: TCheckBox;
- GroupBox5: TGroupBox;
- cb_MB_SETFOREGROUND: TCheckBox;
- NewStaticText1: TNewStaticText;
- NewEdit1: TEdit;
- UpDown1: TUpDown;
- GroupBox6: TGroupBox;
- cb_MsgBox: TRadioButton;
- cb_TaskDialogMsgBox: TRadioButton;
- rb_IDOK: TCheckBox;
- rb_IDCANCEL: TCheckBox;
- rb_IDYES: TCheckBox;
- rb_IDNO: TCheckBox;
- rb_IDABORT: TCheckBox;
- rb_IDRETRY: TCheckBox;
- rb_IDIGNORE: TCheckBox;
- TaskInstructionLabel: TNewStaticText;
- TaskMessageLabel: TNewStaticText;
- TaskInstructionText: TEdit;
- TaskMessageText: TEdit;
- Button1Text: TEdit;
- Button2Text: TEdit;
- Button3Text: TEdit;
- Button1Label: TNewStaticText;
- Button2Label: TNewStaticText;
- Button3Label: TNewStaticText;
- cb_Suppressible: TCheckBox;
- cb_DefIDOK: TRadioButton;
- cb_DefIDCANCEL: TRadioButton;
- cb_DefIDYES: TRadioButton;
- cb_DefIDNO: TRadioButton;
- cb_DefIDABORT: TRadioButton;
- cb_DefIDRETRY: TRadioButton;
- cb_DefIDIGNORE: TRadioButton;
- procedure FormCreate(Sender: TObject);
- procedure UpDown1Changing(Sender: TObject; var AllowChange: Boolean);
- procedure rbMB_OKClick(Sender: TObject);
- procedure rbMB_OKCANCELClick(Sender: TObject);
- procedure rbMB_YESNOClick(Sender: TObject);
- procedure rbMB_RETRYCANCELClick(Sender: TObject);
- procedure rbMB_YESNOCANCELClick(Sender: TObject);
- procedure rbMB_ABORTRETRYIGNOREClick(Sender: TObject);
- procedure MBDButtonPreviewClick(Sender: TObject);
- procedure cb_TaskDialogMsgBoxClick(Sender: TObject);
- procedure cb_MsgBoxClick(Sender: TObject);
- procedure rb_IDOKClick(Sender: TObject);
- procedure rb_IDCANCELClick(Sender: TObject);
- procedure rb_IDNOClick(Sender: TObject);
- procedure rb_IDYESClick(Sender: TObject);
- procedure rb_IDRETRYClick(Sender: TObject);
- procedure rb_IDIGNOREClick(Sender: TObject);
- procedure rb_IDABORTClick(Sender: TObject);
- procedure cb_SuppressibleClick(Sender: TObject);
- procedure MSGTextKeyPress(Sender: TObject; var Key: Char);
- public
- function GetText(TabWidth: Integer; UseTabCharacter: Boolean): String;
- end;
- implementation
- uses
- Shared.CommonFunc.Vcl, Shared.CommonFunc, IDE.HelperFunc, Shared.TaskDialogFunc, IDE.Messages;
- {$R *.DFM}
- procedure TMsgBoxDesignerForm.FormCreate(Sender: TObject);
- begin
- InitFormFont(Self);
- InitFormTheme(Self);
- cb_Suppressible.Checked := True;
- MSGText.Lines[MSGText.CaretPos.Y] := '<Enter your text here...>';
- MSGText.SelStart := MSGText.Perform(EM_LINEINDEX, 0, 0);
- MSGText.SelLength := Length(MSGText.Lines[0]);
- cb_IDCANCEL.Enabled := False;
- cb_IDABORT.Enabled := False;
- cb_IDRETRY.Enabled := False;
- cb_IDIGNORE.Enabled := False;
- cb_IDYES.Enabled := False;
- cb_IDNO.Enabled := False;
- NewStaticText1.Enabled := False;
- NewEdit1.Enabled := False;
- UpDown1.Enabled := False;
- TaskInstructionLabel.Visible := False;
- TaskMessageLabel.Visible := False;
- TaskInstructionText.Visible := False;
- TaskMessageText.Visible := False;
- Button1Text.Visible := False;
- Button2Text.Visible := False;
- Button3Text.Visible := False;
- Button1Label.Visible := False;
- Button2Label.Visible := False;
- Button3Label.Visible := False;
- end;
- procedure TMsgBoxDesignerForm.rbMB_OKClick(Sender: TObject);
- begin
- cb_IDOK.Checked := False;
- cb_IDCANCEL.Checked := False;
- cb_IDABORT.Checked := False;
- cb_IDRETRY.Checked := False;
- cb_IDIGNORE.Checked := False;
- cb_IDYES.Checked := False;
- cb_IDNO.Checked := False;
- cb_IDOK.Enabled := False;
- cb_IDCANCEL.Enabled := False;
- cb_IDABORT.Enabled := False;
- cb_IDRETRY.Enabled := False;
- cb_IDIGNORE.Enabled := False;
- cb_IDYES.Enabled := False;
- cb_IDNO.Enabled := False;
- NewStaticText1.Enabled := False;
- NewEdit1.Enabled := False;
- NewEdit1.Text := '1';
- UpDown1.Enabled := False;
- if cb_TaskDialogMsgBox.Checked then begin
- rb_IDOK.Enabled := True;
- rb_IDCANCEL.Enabled := False;
- rb_IDABORT.Enabled := False;
- rb_IDRETRY.Enabled := False;
- rb_IDIGNORE.Enabled := False;
- rb_IDYES.Enabled := False;
- rb_IDNO.Enabled := False;
- rb_IDOK.Checked := False;
- rb_IDCANCEL.Checked := False;
- rb_IDABORT.Checked := False;
- rb_IDRETRY.Checked := False;
- rb_IDIGNORE.Checked := False;
- rb_IDYES.Checked := False;
- rb_IDNO.Checked := False;
- Button3Text.Enabled := False;
- Button3Label.Enabled := False;
- Button2Text.Enabled := False;
- Button2Label.Enabled := False;
- Button1Text.Enabled := True;
- Button1Label.Enabled := True;
- Button1Text.Text := 'OK';
- Button2Text.Text := '';
- Button3Text.Text := '';
- end;
- if cb_Suppressible.Checked then begin
- cb_DefIDOK.Checked := True;
- cb_DefIDCANCEL.Checked := False;
- cb_DefIDYES.Checked := False;
- cb_DefIDNO.Checked := False;
- cb_DefIDABORT.Checked := False;
- cb_DefIDRETRY.Checked := False;
- cb_DefIDIGNORE.Checked := False;
- cb_DefIDOK.Enabled := True;
- cb_DefIDCANCEL.Enabled := False;
- cb_DefIDYES.Enabled := False;
- cb_DefIDNO.Enabled := False;
- cb_DefIDABORT.Enabled := False;
- cb_DefIDRETRY.Enabled := False;
- cb_DefIDIGNORE.Enabled := False;
- end;
- end;
- procedure TMsgBoxDesignerForm.rbMB_YESNOClick(Sender: TObject);
- begin
- cb_IDOK.Checked := False;
- cb_IDCANCEL.Checked := False;
- cb_IDABORT.Checked := False;
- cb_IDRETRY.Checked := False;
- cb_IDIGNORE.Checked := False;
- cb_IDYES.Checked := False;
- cb_IDNO.Checked := False;
- cb_IDOK.Enabled := False;
- cb_IDCANCEL.Enabled := False;
- cb_IDABORT.Enabled := False;
- cb_IDRETRY.Enabled := False;
- cb_IDIGNORE.Enabled := False;
- cb_IDYES.Enabled := True;
- cb_IDNO.Enabled := True;
- if not cb_TaskDialogMsgBox.Checked then begin
- NewStaticText1.Enabled := True;
- NewEdit1.Enabled := True;
- NewEdit1.Text := '1';
- UpDown1.Max := 2;
- UpDown1.Enabled := True;
- end;
- if cb_TaskDialogMsgBox.Checked then begin
- rb_IDOK.Enabled := False;
- rb_IDCANCEL.Enabled := False;
- rb_IDABORT.Enabled := False;
- rb_IDRETRY.Enabled := False;
- rb_IDIGNORE.Enabled := False;
- rb_IDYES.Enabled := True;
- rb_IDNO.Enabled := True;
- rb_IDOK.Checked := False;
- rb_IDCANCEL.Checked := False;
- rb_IDABORT.Checked := False;
- rb_IDRETRY.Checked := False;
- rb_IDIGNORE.Checked := False;
- rb_IDYES.Checked := False;
- rb_IDNO.Checked := False;
- Button3Text.Enabled := False;
- Button3Label.Enabled := False;
- Button2Text.Enabled := True;
- Button2Label.Enabled := True;
- Button1Text.Enabled := True;
- Button1Label.Enabled := True;
- Button1Text.Text := 'Yes';
- Button2Text.Text := 'No';
- Button3Text.Text := '';
- end;
- if cb_Suppressible.Checked then begin
- cb_DefIDOK.Checked := False;
- cb_DefIDCANCEL.Checked := False;
- cb_DefIDYES.Checked := True;
- cb_DefIDNO.Checked := False;
- cb_DefIDABORT.Checked := False;
- cb_DefIDRETRY.Checked := False;
- cb_DefIDIGNORE.Checked := False;
- cb_DefIDOK.Enabled := False;
- cb_DefIDCANCEL.Enabled := False;
- cb_DefIDYES.Enabled := True;
- cb_DefIDNO.Enabled := True;
- cb_DefIDABORT.Enabled := False;
- cb_DefIDRETRY.Enabled := False;
- cb_DefIDIGNORE.Enabled := False;
- end;
- end;
- procedure TMsgBoxDesignerForm.rbMB_OKCANCELClick(Sender: TObject);
- begin
- cb_IDOK.Checked := False;
- cb_IDCANCEL.Checked := False;
- cb_IDABORT.Checked := False;
- cb_IDRETRY.Checked := False;
- cb_IDIGNORE.Checked := False;
- cb_IDYES.Checked := False;
- cb_IDNO.Checked := False;
- cb_IDOK.Enabled := True;
- cb_IDCANCEL.Enabled := True;
- cb_IDABORT.Enabled := False;
- cb_IDRETRY.Enabled := False;
- cb_IDIGNORE.Enabled := False;
- cb_IDYES.Enabled := False;
- cb_IDNO.Enabled := False;
- if not cb_TaskDialogMsgBox.Checked then begin
- NewStaticText1.Enabled := True;
- NewEdit1.Enabled := True;
- NewEdit1.Text := '1';
- UpDown1.Max := 2;
- UpDown1.Enabled := True;
- end;
- if cb_TaskDialogMsgBox.Checked then begin
- rb_IDOK.Enabled := True;
- rb_IDCANCEL.Enabled := True;
- rb_IDABORT.Enabled := False;
- rb_IDRETRY.Enabled := False;
- rb_IDIGNORE.Enabled := False;
- rb_IDYES.Enabled := False;
- rb_IDNO.Enabled := False;
- rb_IDOK.Checked := False;
- rb_IDCANCEL.Checked := False;
- rb_IDABORT.Checked := False;
- rb_IDRETRY.Checked := False;
- rb_IDIGNORE.Checked := False;
- rb_IDYES.Checked := False;
- rb_IDNO.Checked := False;
- Button3Text.Enabled := False;
- Button3Label.Enabled := False;
- Button2Text.Enabled := True;
- Button2Label.Enabled := True;
- Button1Text.Enabled := True;
- Button1Label.Enabled := True;
- Button1Text.Text := 'OK';
- Button2Text.Text := 'Cancel';
- Button3Text.Text := '';
- end;
- if cb_Suppressible.Checked then begin
- cb_DefIDOK.Checked := True;
- cb_DefIDCANCEL.Checked := False;
- cb_DefIDYES.Checked := False;
- cb_DefIDNO.Checked := False;
- cb_DefIDABORT.Checked := False;
- cb_DefIDRETRY.Checked := False;
- cb_DefIDIGNORE.Checked := False;
- cb_DefIDOK.Enabled := True;
- cb_DefIDCANCEL.Enabled := True;
- cb_DefIDYES.Enabled := False;
- cb_DefIDNO.Enabled := False;
- cb_DefIDABORT.Enabled := False;
- cb_DefIDRETRY.Enabled := False;
- cb_DefIDIGNORE.Enabled := False;
- end;
- end;
- procedure TMsgBoxDesignerForm.rbMB_RETRYCANCELClick(Sender: TObject);
- begin
- cb_IDOK.Checked := False;
- cb_IDCANCEL.Checked := False;
- cb_IDABORT.Checked := False;
- cb_IDRETRY.Checked := False;
- cb_IDIGNORE.Checked := False;
- cb_IDYES.Checked := False;
- cb_IDNO.Checked := False;
- cb_IDOK.Enabled := False;
- cb_IDCANCEL.Enabled := True;
- cb_IDABORT.Enabled := False;
- cb_IDRETRY.Enabled := True;
- cb_IDIGNORE.Enabled := False;
- cb_IDYES.Enabled := False;
- cb_IDNO.Enabled := False;
- if not cb_TaskDialogMsgBox.Checked then begin
- NewStaticText1.Enabled := True;
- NewEdit1.Enabled := True;
- NewEdit1.Text := '1';
- UpDown1.Max := 2;
- UpDown1.Enabled := True;
- end;
- if cb_TaskDialogMsgBox.Checked then begin
- rb_IDOK.Enabled := False;
- rb_IDCANCEL.Enabled := True;
- rb_IDABORT.Enabled := False;
- rb_IDRETRY.Enabled := True;
- rb_IDIGNORE.Enabled := False;
- rb_IDYES.Enabled := False;
- rb_IDNO.Enabled := False;
- rb_IDOK.Checked := False;
- rb_IDCANCEL.Checked := False;
- rb_IDABORT.Checked := False;
- rb_IDRETRY.Checked := False;
- rb_IDIGNORE.Checked := False;
- rb_IDYES.Checked := False;
- rb_IDNO.Checked := False;
- Button3Text.Enabled := False;
- Button3Label.Enabled := False;
- Button2Text.Enabled := True;
- Button2Label.Enabled := True;
- Button1Text.Enabled := True;
- Button1Label.Enabled := True;
- Button1Text.Text := 'Retry';
- Button2Text.Text := 'Cancel';
- Button3Text.Text := '';
- end;
- if cb_Suppressible.Checked then begin
- cb_DefIDOK.Checked := False;
- cb_DefIDCANCEL.Checked := True;
- cb_DefIDYES.Checked := False;
- cb_DefIDNO.Checked := False;
- cb_DefIDABORT.Checked := False;
- cb_DefIDRETRY.Checked := False;
- cb_DefIDIGNORE.Checked := False;
- cb_DefIDOK.Enabled := False;
- cb_DefIDCANCEL.Enabled := True;
- cb_DefIDYES.Enabled := False;
- cb_DefIDNO.Enabled := False;
- cb_DefIDABORT.Enabled := False;
- cb_DefIDRETRY.Enabled := True;
- cb_DefIDIGNORE.Enabled := False;
- end;
- end;
- procedure TMsgBoxDesignerForm.rbMB_YESNOCANCELClick(Sender: TObject);
- begin
- cb_IDOK.Checked := False;
- cb_IDCANCEL.Checked := False;
- cb_IDABORT.Checked := False;
- cb_IDRETRY.Checked := False;
- cb_IDIGNORE.Checked := False;
- cb_IDYES.Checked := False;
- cb_IDNO.Checked := False;
- cb_IDOK.Enabled := False;
- cb_IDCANCEL.Enabled := True;
- cb_IDABORT.Enabled := False;
- cb_IDRETRY.Enabled := False;
- cb_IDIGNORE.Enabled := False;
- cb_IDYES.Enabled := True;
- cb_IDNO.Enabled := True;
- if not cb_TaskDialogMsgBox.Checked then begin
- NewStaticText1.Enabled := True;
- NewEdit1.Enabled := True;
- NewEdit1.Text := '1';
- UpDown1.Max := 3;
- UpDown1.Enabled := True;
- end;
- if cb_TaskDialogMsgBox.Checked then begin
- rb_IDOK.Enabled := False;
- rb_IDCANCEL.Enabled := True;
- rb_IDABORT.Enabled := False;
- rb_IDRETRY.Enabled := False;
- rb_IDIGNORE.Enabled := False;
- rb_IDYES.Enabled := True;
- rb_IDNO.Enabled := True;
- rb_IDOK.Checked := False;
- rb_IDCANCEL.Checked := False;
- rb_IDABORT.Checked := False;
- rb_IDRETRY.Checked := False;
- rb_IDIGNORE.Checked := False;
- rb_IDYES.Checked := False;
- rb_IDNO.Checked := False;
- Button3Text.Enabled := True;
- Button3Label.Enabled := True;
- Button2Text.Enabled := True;
- Button2Label.Enabled := True;
- Button1Text.Enabled := True;
- Button1Label.Enabled := True;
- Button1Text.Text := 'Yes';
- Button2Text.Text := 'No';
- Button3Text.Text := 'Cancel';
- end;
- if cb_Suppressible.Checked then begin
- cb_DefIDOK.Checked := False;
- cb_DefIDCANCEL.Checked := False;
- cb_DefIDYES.Checked := True;
- cb_DefIDNO.Checked := False;
- cb_DefIDABORT.Checked := False;
- cb_DefIDRETRY.Checked := False;
- cb_DefIDIGNORE.Checked := False;
- cb_DefIDOK.Enabled := False;
- cb_DefIDCANCEL.Enabled := True;
- cb_DefIDYES.Enabled := True;
- cb_DefIDNO.Enabled := True;
- cb_DefIDABORT.Enabled := False;
- cb_DefIDRETRY.Enabled := False;
- cb_DefIDIGNORE.Enabled := False;
- end;
- end;
- procedure TMsgBoxDesignerForm.rbMB_ABORTRETRYIGNOREClick(Sender: TObject);
- begin
- cb_IDOK.Checked := False;
- cb_IDCANCEL.Checked := False;
- cb_IDABORT.Checked := False;
- cb_IDRETRY.Checked := False;
- cb_IDIGNORE.Checked := False;
- cb_IDYES.Checked := False;
- cb_IDNO.Checked := False;
- cb_IDOK.Enabled := False;
- cb_IDCANCEL.Enabled := False;
- cb_IDABORT.Enabled := True;
- cb_IDRETRY.Enabled := True;
- cb_IDIGNORE.Enabled := True;
- cb_IDYES.Enabled := False;
- cb_IDNO.Enabled := False;
- if not cb_TaskDialogMsgBox.Checked then begin
- NewStaticText1.Enabled := True;
- NewEdit1.Enabled := True;
- NewEdit1.Text := '1';
- UpDown1.Max := 3;
- UpDown1.Enabled := True;
- end;
- if cb_TaskDialogMsgBox.Checked then begin
- rb_IDOK.Enabled := False;
- rb_IDCANCEL.Enabled := False;
- rb_IDABORT.Enabled := True;
- rb_IDRETRY.Enabled := True;
- rb_IDIGNORE.Enabled := True;
- rb_IDYES.Enabled := False;
- rb_IDNO.Enabled := False;
- rb_IDOK.Checked := False;
- rb_IDCANCEL.Checked := False;
- rb_IDABORT.Checked := False;
- rb_IDRETRY.Checked := False;
- rb_IDIGNORE.Checked := False;
- rb_IDYES.Checked := False;
- rb_IDNO.Checked := False;
- Button3Text.Enabled := True;
- Button3Label.Enabled := True;
- Button2Text.Enabled := True;
- Button2Label.Enabled := True;
- Button1Text.Enabled := True;
- Button1Label.Enabled := True;
- Button1Text.Text := 'Retry'; //this order is not a mistake
- Button2Text.Text := 'Ignore'; //
- Button3Text.Text := 'Abort'; //
- end;
- if cb_Suppressible.Checked then begin
- cb_DefIDOK.Checked := False;
- cb_DefIDCANCEL.Checked := False;
- cb_DefIDYES.Checked := False;
- cb_DefIDNO.Checked := False;
- cb_DefIDABORT.Checked := False;
- cb_DefIDRETRY.Checked := False;
- cb_DefIDIGNORE.Checked := True;
- cb_DefIDOK.Enabled := False;
- cb_DefIDCANCEL.Enabled := False;
- cb_DefIDYES.Enabled := False;
- cb_DefIDNO.Enabled := False;
- cb_DefIDABORT.Enabled := True;
- cb_DefIDRETRY.Enabled := True;
- cb_DefIDIGNORE.Enabled := True;
- end;
- end;
- procedure TMsgBoxDesignerForm.UpDown1Changing(Sender: TObject; var AllowChange: Boolean);
- begin
- AllowChange := True;
- end;
- procedure TMsgBoxDesignerForm.cb_MsgBoxClick(Sender: TObject);
- begin
- IMGmbConfirmation.Visible := True;
- cb_MB_SETFOREGROUND.Enabled := True;
- cb_MB_SETFOREGROUND.Checked := False;
- GroupBox1.Visible := True;
- if not cb_Suppressible.Checked then begin
- GroupBox4.Caption := ' Return values ';
- cb_DefIDOK.Visible := False;
- cb_DefIDCANCEL.Visible := False;
- cb_DefIDYES.Visible := False;
- cb_DefIDNO.Visible := False;
- cb_DefIDABORT.Visible := False;
- cb_DefIDRETRY.Visible := False;
- cb_DefIDIGNORE.Visible := False;
- end
- else begin
- GroupBox4.Caption := ' Return values / -------- / Default ';
- cb_DefIDOK.Visible := True;
- cb_DefIDCANCEL.Visible := True;
- cb_DefIDYES.Visible := True;
- cb_DefIDNO.Visible := True;
- cb_DefIDABORT.Visible := True;
- cb_DefIDRETRY.Visible := True;
- cb_DefIDIGNORE.Visible := True;
- end;
- cb_IDOK.Checked := False;
- cb_IDCANCEL.Checked := False;
- cb_IDABORT.Checked := False;
- cb_IDRETRY.Checked := False;
- cb_IDIGNORE.Checked := False;
- cb_IDYES.Checked := False;
- cb_IDNO.Checked := False;
- rb_IDOK.Visible := False;
- rb_IDCANCEL.Visible := False;
- rb_IDABORT.Visible := False;
- rb_IDRETRY.Visible := False;
- rb_IDIGNORE.Visible := False;
- rb_IDYES.Visible := False;
- rb_IDNO.Visible := False;
- rb_mbInformation.Checked := True;
- TaskInstructionLabel.Visible := False;
- TaskMessageLabel.Visible := False;
- TaskInstructionText.Visible := False;
- TaskMessageText.Visible := False;
- Button1Text.Visible := False;
- Button2Text.Visible := False;
- Button3Text.Visible := False;
- Button1Label.Visible := False;
- Button2Label.Visible := False;
- Button3Label.Visible := False;
- rbMB_OK.Checked := True;
- rbMB_OKClick(Self);
- end;
- procedure TMsgBoxDesignerForm.cb_SuppressibleClick(Sender: TObject);
- begin
- if cb_Suppressible.Checked then begin
- cb_DefIDOK.Visible := True;
- cb_DefIDCANCEL.Visible := True;
- cb_DefIDYES.Visible := True;
- cb_DefIDNO.Visible := True;
- cb_DefIDABORT.Visible := True;
- cb_DefIDRETRY.Visible := True;
- cb_DefIDIGNORE.Visible := True;
- if cb_MsgBox.Checked then
- GroupBox4.Caption := ' Return values / -------- / Default ';
- if cb_TaskDialogMsgBox.Checked then
- GroupBox4.Caption := ' Return values / Shield / Default ';
- end
- else begin
- cb_DefIDOK.Checked := False;
- cb_DefIDCANCEL.Checked := False;
- cb_DefIDYES.Checked := False;
- cb_DefIDNO.Checked := False;
- cb_DefIDABORT.Checked := False;
- cb_DefIDRETRY.Checked := False;
- cb_DefIDIGNORE.Checked := False;
- cb_DefIDOK.Visible := False;
- cb_DefIDCANCEL.Visible := False;
- cb_DefIDYES.Visible := False;
- cb_DefIDNO.Visible := False;
- cb_DefIDABORT.Visible := False;
- cb_DefIDRETRY.Visible := False;
- cb_DefIDIGNORE.Visible := False;
- if cb_MsgBox.Checked then
- GroupBox4.Caption := ' Return values ';
- if cb_TaskDialogMsgBox.Checked then
- GroupBox4.Caption := ' Return values / Shield ';
- end;
- if rbMB_OK.Checked then rbMB_OKClick(Self);
- if rbMB_OKCANCEL.Checked then rbMB_OKCANCELClick(Self);
- if rbMB_YESNO.Checked then rbMB_YESNOClick(Self);
- if rbMB_YESNOCANCEL.Checked then rbMB_YESNOCANCELClick(Self);
- if rbMB_RETRYCANCEL.Checked then rbMB_RETRYCANCELClick(Self);
- if rbMB_ABORTRETRYIGNORE.Checked then rbMB_ABORTRETRYIGNOREClick(Self);
- end;
- procedure TMsgBoxDesignerForm.cb_TaskDialogMsgBoxClick(Sender: TObject);
- begin
- IMGmbConfirmation.Visible := False;
- cb_MB_SETFOREGROUND.Enabled := False;
- cb_MB_SETFOREGROUND.Checked := False;
- GroupBox1.Visible := False;
- if not cb_Suppressible.Checked then begin
- GroupBox4.Caption := ' Return values / Shield ';
- cb_DefIDOK.Visible := False;
- cb_DefIDCANCEL.Visible := False;
- cb_DefIDYES.Visible := False;
- cb_DefIDNO.Visible := False;
- cb_DefIDABORT.Visible := False;
- cb_DefIDRETRY.Visible := False;
- cb_DefIDIGNORE.Visible := False;
- end
- else begin
- GroupBox4.Caption := ' Return values / Shield / Default ';
- cb_DefIDOK.Visible := True;
- cb_DefIDCANCEL.Visible := True;
- cb_DefIDYES.Visible := True;
- cb_DefIDNO.Visible := True;
- cb_DefIDABORT.Visible := True;
- cb_DefIDRETRY.Visible := True;
- cb_DefIDIGNORE.Visible := True;
- end;
- cb_IDOK.Checked := False;
- cb_IDCANCEL.Checked := False;
- cb_IDABORT.Checked := False;
- cb_IDRETRY.Checked := False;
- cb_IDIGNORE.Checked := False;
- cb_IDYES.Checked := False;
- cb_IDNO.Checked := False;
- rb_IDOK.Checked := False;
- rb_IDCANCEL.Checked := False;
- rb_IDABORT.Checked := False;
- rb_IDRETRY.Checked := False;
- rb_IDIGNORE.Checked := False;
- rb_IDYES.Checked := False;
- rb_IDNO.Checked := False;
- rb_IDOK.Visible := True;
- rb_IDCANCEL.Visible := True;
- rb_IDABORT.Visible := True;
- rb_IDRETRY.Visible := True;
- rb_IDIGNORE.Visible := True;
- rb_IDYES.Visible := True;
- rb_IDNO.Visible := True;
- rb_mbInformation.Checked := True;
- TaskInstructionLabel.Visible := True;
- TaskMessageLabel.Visible := True;
- TaskInstructionText.Visible := True;
- TaskMessageText.Visible := True;
- Button1Text.Visible := True;
- Button2Text.Visible := True;
- Button3Text.Visible := True;
- Button1Label.Visible := True;
- Button2Label.Visible := True;
- Button3Label.Visible := True;
- TaskInstructionText.Text := 'Instruction Text';
- TaskMessageText.Text := 'Message Text';
- rbMB_OK.Checked := True;
- rbMB_OKClick(Self);
- end;
- procedure TMsgBoxDesignerForm.rb_IDOKClick(Sender: TObject);
- begin
- if rb_IDOK.Checked then
- rb_IDCANCEL.Checked := False;
- end;
- procedure TMsgBoxDesignerForm.rb_IDCANCELClick(Sender: TObject);
- begin
- if rb_IDCANCEL.Checked then begin
- rb_IDOK.Checked := False;
- rb_IDNO.Checked := False;
- rb_IDYES.Checked := False;
- rb_IDRETRY.Checked := False;
- end;
- end;
- procedure TMsgBoxDesignerForm.rb_IDYESClick(Sender: TObject);
- begin
- if rb_IDYES.Checked then begin
- rb_IDNO.Checked := False;
- rb_IDCANCEL.Checked := False;
- end;
- end;
- procedure TMsgBoxDesignerForm.rb_IDNOClick(Sender: TObject);
- begin
- if rb_IDNO.Checked then begin
- rb_IDYES.Checked := False;
- rb_IDCANCEL.Checked := False;
- end;
- end;
- procedure TMsgBoxDesignerForm.rb_IDRETRYClick(Sender: TObject);
- begin
- if rb_IDRETRY.Checked then begin
- rb_IDCANCEL.Checked := False;
- rb_IDABORT.Checked := False;
- rb_IDIGNORE.Checked := False;
- end;
- end;
- procedure TMsgBoxDesignerForm.rb_IDIGNOREClick(Sender: TObject);
- begin
- if rb_IDIGNORE.Checked then begin
- rb_IDABORT.Checked := False;
- rb_IDRETRY.Checked := False;
- end;
- end;
- procedure TMsgBoxDesignerForm.rb_IDABORTClick(Sender: TObject);
- begin
- if rb_IDABORT.Checked then begin
- rb_IDIGNORE.Checked := False;
- rb_IDRETRY.Checked := False;
- end;
- end;
- procedure TMsgBoxDesignerForm.MBDButtonPreviewClick(Sender: TObject);
- begin
- { default value }
- var Buttons := MB_OK;
- var Typ := mbInformation;
- { icon and caption set }
- var Caption: String;
- if rb_mbInformation.Checked then begin
- Caption := 'Info';
- Typ := mbInformation;
- end;
- if rb_mbConfirmation.Checked then begin
- Caption := 'Confirm';
- Typ := mbConfirmation;
- end;
- if rb_mbError.Checked then begin
- Caption := 'Error';
- Typ := mbError;
- end;
- if rb_mbCriticalError.Checked then begin
- Caption := 'Fatal Error';
- Typ := mbCriticalError;
- end;
- { button type set }
- if rbMB_OK.Checked then Buttons := MB_OK;
- if rbMB_OKCANCEL.Checked then Buttons := MB_OKCANCEL;
- if rbMB_YESNO.Checked then Buttons := MB_YESNO;
- if rbMB_YESNOCANCEL.Checked then Buttons := MB_YESNOCANCEL;
- if rbMB_RETRYCANCEL.Checked then Buttons := MB_RETRYCANCEL;
- if rbMB_ABORTRETRYIGNORE.Checked then Buttons := MB_ABORTRETRYIGNORE;
- if cb_MsgBox.Checked then begin
- if MSGText.GetTextLen = 0 then
- MSGText.Lines.Add('Your message text.');
- { MessageBox with DefButton }
- if NewEdit1.Text = '1' then
- MsgBox(MSGText.Lines.GetText, Caption, Typ, Buttons);
- if NewEdit1.Text = '2' then
- MsgBox(MSGText.Lines.GetText, Caption, Typ, Buttons or MB_DEFBUTTON2);
- if NewEdit1.Text = '3' then
- MsgBox(MSGText.Lines.GetText, Caption, Typ, Buttons or MB_DEFBUTTON3);
- { MessageBox with DefButton and Flag MB_SETFOREGROUND }
- if (NewEdit1.Text = '1') and (cb_MB_SETFOREGROUND.Checked) then
- MsgBox(MSGText.Lines.GetText, Caption, Typ, Buttons or MB_SETFOREGROUND);
- if (NewEdit1.Text = '2') and (cb_MB_SETFOREGROUND.Checked) then
- MsgBox(MSGText.Lines.GetText, Caption, Typ, Buttons or MB_DEFBUTTON2 or MB_SETFOREGROUND);
- if (NewEdit1.Text = '3') and (cb_MB_SETFOREGROUND.Checked) then
- MsgBox(MSGText.Lines.GetText, Caption, Typ, Buttons or MB_DEFBUTTON3 or MB_SETFOREGROUND);
- end else if cb_TaskDialogMsgBox.Checked then begin
- { create ButtonLabels array - also see GetText}
- var ButtonLabels: TArray<string>;
- if Button3Text.Enabled then
- ButtonLabels := TArray<string>.Create(Button1Text.Text, Button2Text.Text, Button3Text.Text)
- else if Button2Text.Enabled then
- ButtonLabels := TArray<string>.Create(Button1Text.Text, Button2Text.Text)
- else
- ButtonLabels := TArray<string>.Create(Button1Text.Text);
- if rbMB_OKCANCEL.Checked or rbMB_YESNOCANCEL.Checked or rbMB_RETRYCANCEL.Checked then begin
- { Specifying a cancel label is optional: if it's missing TaskDialogMsgBox will use a button
- at the bottom instead }
- const NLabels = Length(ButtonLabels);
- if ButtonLabels[NLabels-1] = '' then
- SetLength(ButtonLabels, NLabels-1);
- end;
- { get Shield Flag value }
- var ShieldButton := 0;
- if rbMB_OK.Checked and rb_IDOK.Checked then ShieldButton := IDOK;
- if rbMB_OKCANCEL.Checked and rb_IDOK.Checked then ShieldButton := IDOK;
- if rbMB_OKCANCEL.Checked and rb_IDCANCEL.Checked then ShieldButton := IDCANCEL;
- if rbMB_YESNO.Checked and rb_IDYES.Checked then ShieldButton := IDYES;
- if rbMB_YESNO.Checked and rb_IDNO.Checked then ShieldButton := IDNO;
- if rbMB_YESNOCANCEL.Checked and rb_IDYES.Checked then ShieldButton := IDYES;
- if rbMB_YESNOCANCEL.Checked and rb_IDNO.Checked then ShieldButton := IDNO;
- if rbMB_YESNOCANCEL.Checked and rb_IDCANCEL.Checked then ShieldButton := IDCANCEL;
- if rbMB_RETRYCANCEL.Checked and rb_IDRETRY.Checked then ShieldButton := IDRETRY;
- if rbMB_RETRYCANCEL.Checked and rb_IDCANCEL.Checked then ShieldButton := IDCANCEL;
- if rbMB_ABORTRETRYIGNORE.Checked and rb_IDRETRY.Checked then ShieldButton := IDRETRY;
- if rbMB_ABORTRETRYIGNORE.Checked and rb_IDABORT.Checked then ShieldButton := IDABORT;
- if rbMB_ABORTRETRYIGNORE.Checked and rb_IDIGNORE.Checked then ShieldButton := IDIGNORE;
- { TaskDialogMsgBox(Icon, Instruction, Text, Caption, Typ, Buttons, ButtonLabels, ShieldButton) }
- TaskDialogMsgBox('', TaskInstructionText.Text, TaskMessageText.Text, Caption,
- Typ, Buttons, ButtonLabels, ShieldButton);
- end;
- end;
- procedure TMsgBoxDesignerForm.MSGTextKeyPress(Sender: TObject; var Key: Char);
- begin
- if Key = #27 then begin
- MBDButtonCancel.Click;
- Key := #0;
- end;
- end;
- function TMsgBoxDesignerForm.GetText(TabWidth: Integer; UseTabCharacter: Boolean): String;
- function TextTab: String;
- begin
- if UseTabCharacter then
- Result := #9
- else
- Result := Format('%*s', [TabWidth, '']);
- end;
- function TextUserClicked(IDButton: String): String;
- begin
- Result := 'user clicked ' + StringReplace(IDButton, 'ID', '', [])
- end;
- function TextCase(IDButton: String): String;
- begin
- Result := TextTab + IDButton +': { ' + TextUserClicked(IDButton) + ' };';
- end;
- function TextCall(ButtonCount: Integer; SCall, IDButton, IDButton2, IDButton3: String): String;
- begin
- case ButtonCount of
- 0: Result := SCall + ';';
- 1: Result := 'if ' + SCall + ' = ' + IDButton + ' then' + SNewLine +
- 'begin' + SNewLine +
- TextTab + '// ' + TextUserClicked(IDButton) + SNewLine +
- 'end;';
- 2, 3:
- begin
- Result := 'case ' + SCall + ' of ' + SNewLine +
- TextCase(IDButton) + SNewLine +
- TextCase(IDButton2) + SNewLine;
- if ButtonCount = 3 then
- Result := Result + TextCase(IDButton3) + SNewLine;
- Result := Result + 'end;';
- end;
- end;
- end;
- { MsgBox / SuppressibleMsgBox }
- function TextMsgBox(ButtonCount: Integer; Caption, Typ, Buttons,
- IDButton, IDButton2, IDButton3: String): String;
- begin
- var SMsgBox: String;
- if not cb_Suppressible.Checked then
- SMsgBox := 'MsgBox'
- else
- SMsgBox := 'SuppressibleMsgBox';
- //Buttons also contains Default if suppressible, pre-separated by a comma (but ButtonCount does *not* include this)
- SMsgBox := SMsgBox + '(''' + Caption + ''', ' + Typ + ', ' + Buttons + ')';
- Result := TextCall(ButtonCount, SMsgBox, IDButton, IDButton2, IDButton3);
- end;
- { TaskDialogMsgBox / SuppressibleTaskDialogMsgBox }
- function TextTaskDialog(ButtonCount: Integer; InstructionAndText, Typ, Buttons,
- ButtonLabels, ShieldButton, IDButton, IDButton2, IDButton3: String): String;
- begin
- var STaskDialog: String;
- if not cb_Suppressible.Checked then
- STaskDialog := 'TaskDialogMsgBox'
- else
- STaskDialog := 'SuppressibleTaskDialogMsgBox';
- //InstructionAndText contains both Instruction and Text, pre-separated by a quote, a comma and another quote
- //ButtonLabels contains all labels, also pre-separated by the above
- //ShieldButton also contains Default if suppressible, pre-separated by a comma (but ButtonCount does *not* include this)
- STaskDialog := STaskDialog+ '(''' + InstructionAndText + ''', ' + Typ + ', ' + Buttons + ', [''' + ButtonLabels + '''], ' + ShieldButton + ')';
- Result := TextCall(ButtonCount, STaskDialog, IDButton, IDButton2, IDButton3);
- end;
- begin
- { default value }
- var ButtonCount := 0;
- var Buttons := 'MB_OK';
- var Typ := 'mbInformation';
- var ShieldButton: String := '0';
- var SuppressibleDefault := '';
- { make a string with Default parameter for Suppressible* calls }
- if cb_Suppressible.Checked then begin
- if cb_DefIDOK.Checked then SuppressibleDefault := ', IDOK';
- if cb_DefIDCANCEL.Checked then SuppressibleDefault := ', IDCANCEL';
- if cb_DefIDYES.Checked then SuppressibleDefault := ', IDYES';
- if cb_DefIDNO.Checked then SuppressibleDefault := ', IDNO';
- if cb_DefIDABORT.Checked then SuppressibleDefault := ', IDABORT';
- if cb_DefIDRETRY.Checked then SuppressibleDefault := ', IDRETRY';
- if cb_DefIDIGNORE.Checked then SuppressibleDefault := ', IDIGNORE';
- end;
- { icon and caption set }
- if rb_mbInformation.Checked then begin
- Typ := 'mbInformation';
- end;
- if rb_mbConfirmation.Checked then begin
- Typ := 'mbConfirmation';
- end;
- if rb_mbError.Checked then begin
- Typ := 'mbError';
- end;
- if rb_mbCriticalError.Checked then begin
- Typ := 'mbCriticalError';
- end;
- { button type set }
- if rbMB_OK.Checked then Buttons := 'MB_OK';
- if rbMB_OKCANCEL.Checked then Buttons := 'MB_OKCANCEL';
- if rbMB_YESNO.Checked then Buttons := 'MB_YESNO';
- if rbMB_YESNOCANCEL.Checked then Buttons := 'MB_YESNOCANCEL';
- if rbMB_RETRYCANCEL.Checked then Buttons := 'MB_RETRYCANCEL';
- if rbMB_ABORTRETRYIGNORE.Checked then Buttons := 'MB_ABORTRETRYIGNORE';
- var ModeMsg: Integer;
- var CaptionOrInstructionAndText: String;
- var ButtonLabels: String;
- if cb_MsgBox.Checked then begin
- { MsgBox(Text, Typ, Buttons); }
- ModeMsg := 0;
- { MessageBox with DefButton and Flag MB_SETFOREGROUND }
- if (rbMB_OK.Checked) and (cb_MB_SETFOREGROUND.Checked) then
- Buttons := 'MB_OK or MB_SETFOREGROUND';
- if (rbMB_OKCANCEL.Checked) and (NewEdit1.Text = '2') then
- Buttons := 'MB_OKCANCEL or MB_DEFBUTTON2';
- { MessageBox with DefButton and Flag MB_SETFOREGROUND }
- if (rbMB_OKCANCEL.Checked) and (cb_MB_SETFOREGROUND.Checked) then
- Buttons := 'MB_OKCANCEL or MB_SETFOREGROUND';
- if (rbMB_OKCANCEL.Checked) and (NewEdit1.Text = '2') and (cb_MB_SETFOREGROUND.Checked) then
- Buttons := 'MB_OKCANCEL or MB_DEFBUTTON2 or MB_SETFOREGROUND';
- if (rbMB_YESNO.Checked) and (NewEdit1.Text = '2') then
- Buttons := 'MB_YESNO or MB_DEFBUTTON2';
- { MessageBox with DefButton and Flag MB_SETFOREGROUND }
- if (rbMB_YESNO.Checked) and (cb_MB_SETFOREGROUND.Checked) then
- Buttons := 'MB_YESNO or MB_SETFOREGROUND';
- if (rbMB_YESNO.Checked) and (NewEdit1.Text = '2') and (cb_MB_SETFOREGROUND.Checked) then
- Buttons := 'MB_YESNO or MB_DEFBUTTON2 or MB_SETFOREGROUND';
- if (rbMB_RETRYCANCEL.Checked) and (NewEdit1.Text = '2') then
- Buttons := 'MB_RETRYCANCEL or MB_DEFBUTTON2';
- { MessageBox with DefButton and Flag MB_SETFOREGROUND }
- if (rbMB_RETRYCANCEL.Checked) and (cb_MB_SETFOREGROUND.Checked) then
- Buttons := 'MB_RETRYCANCEL or MB_SETFOREGROUND';
- if (rbMB_RETRYCANCEL.Checked) and (NewEdit1.Text = '2') and (cb_MB_SETFOREGROUND.Checked) then
- Buttons := 'MB_RETRYCANCEL or MB_DEFBUTTON2 or MB_SETFOREGROUND';
- if (rbMB_YESNOCANCEL.Checked) and (NewEdit1.Text = '2') then
- Buttons := 'MB_YESNOCANCEL or MB_DEFBUTTON2';
- if (rbMB_YESNOCANCEL.Checked) and (NewEdit1.Text = '3') then
- Buttons := 'MB_YESNOCANCEL or MB_DEFBUTTON3';
- { MessageBox with DefButton and Flag MB_SETFOREGROUND }
- if (rbMB_YESNOCANCEL.Checked) and (cb_MB_SETFOREGROUND.Checked) then
- Buttons := 'MB_YESNOCANCEL or MB_SETFOREGROUND';
- if (rbMB_YESNOCANCEL.Checked) and (NewEdit1.Text = '2') and (cb_MB_SETFOREGROUND.Checked) then
- Buttons := 'MB_YESNOCANCEL or MB_DEFBUTTON2 or MB_SETFOREGROUND';
- if (rbMB_YESNOCANCEL.Checked) and (NewEdit1.Text = '3') and (cb_MB_SETFOREGROUND.Checked) then
- Buttons := 'MB_YESNOCANCEL or MB_DEFBUTTON3 or MB_SETFOREGROUND';
- if (rbMB_ABORTRETRYIGNORE.Checked) and (NewEdit1.Text = '2') then
- Buttons := 'MB_ABORTRETRYIGNORE or MB_DEFBUTTON2';
- if (rbMB_ABORTRETRYIGNORE.Checked) and (NewEdit1.Text = '3') then
- Buttons := 'MB_ABORTRETRYIGNORE or MB_DEFBUTTON3';
- { MessageBox with DefButton and Flag MB_SETFOREGROUND }
- if (rbMB_ABORTRETRYIGNORE.Checked) and (cb_MB_SETFOREGROUND.Checked) then
- Buttons := 'MB_ABORTRETRYIGNORE or MB_SETFOREGROUND';
- if (rbMB_ABORTRETRYIGNORE.Checked) and (NewEdit1.Text = '2') and (cb_MB_SETFOREGROUND.Checked) then
- Buttons := 'MB_ABORTRETRYIGNORE or MB_DEFBUTTON2 or MB_SETFOREGROUND';
- if (rbMB_ABORTRETRYIGNORE.Checked) and (NewEdit1.Text = '3') and (cb_MB_SETFOREGROUND.Checked) then
- Buttons := 'MB_ABORTRETRYIGNORE or MB_DEFBUTTON3 or MB_SETFOREGROUND';
- { Suppressible msg }
- if cb_Suppressible.Checked then Buttons := Buttons + SuppressibleDefault;
- { replace in a message string escape /r/n }
- CaptionOrInstructionAndText := StringReplace(MSGText.Lines.GetText, SNewLine, '''#13#10''', [rfReplaceAll]);
- end else begin
- { TaskDialogMsgBox(TaskInstructionText.Text, TaskMessageText.Text, Typ, Buttons, ButtonLabels, ShieldButton) }
- ModeMsg := 1;
- { create ButtonLabels array - also see MBDButtonPreviewClick }
- var ButtonLabelsArray: TArray<string>;
- if Button3Text.Enabled then
- ButtonLabelsArray := TArray<string>.Create(Button1Text.Text, Button2Text.Text, Button3Text.Text)
- else if Button2Text.Enabled then
- ButtonLabelsArray := TArray<string>.Create(Button1Text.Text, Button2Text.Text)
- else
- ButtonLabelsArray := TArray<string>.Create(Button1Text.Text);
- var NLabels := Length(ButtonLabelsArray);
- if rbMB_OKCANCEL.Checked or rbMB_YESNOCANCEL.Checked or rbMB_RETRYCANCEL.Checked then begin
- { Specifying a cancel label is optional: if it's missing TaskDialogMsgBox will use a button
- at the bottom instead }
- if ButtonLabelsArray[NLabels-1] = '' then begin
- Dec(NLabels);
- SetLength(ButtonLabelsArray, NLabels);
- end;
- end;
- for var I := 0 to NLabels-1 do begin { NLabels is always > 0 }
- if I = 0 then
- ButtonLabels := ButtonLabelsArray[I]
- else
- ButtonLabels := ButtonLabels + ''', ''' + ButtonLabelsArray[I];
- end;
- { get Shield Flag value }
- if rbMB_OK.Checked and rb_IDOK.Checked then ShieldButton := 'IDOK';
- if rbMB_OKCANCEL.Checked and rb_IDOK.Checked then ShieldButton := 'IDOK';
- if rbMB_OKCANCEL.Checked and rb_IDCANCEL.Checked then ShieldButton := 'IDCANCEL';
- if rbMB_YESNO.Checked and rb_IDYES.Checked then ShieldButton := 'IDYES';
- if rbMB_YESNO.Checked and rb_IDNO.Checked then ShieldButton := 'IDNO';
- if rbMB_YESNOCANCEL.Checked and rb_IDYES.Checked then ShieldButton := 'IDYES';
- if rbMB_YESNOCANCEL.Checked and rb_IDNO.Checked then ShieldButton := 'IDNO';
- if rbMB_YESNOCANCEL.Checked and rb_IDCANCEL.Checked then ShieldButton := 'IDCANCEL';
- if rbMB_RETRYCANCEL.Checked and rb_IDRETRY.Checked then ShieldButton := 'IDRETRY';
- if rbMB_RETRYCANCEL.Checked and rb_IDCANCEL.Checked then ShieldButton := 'IDCANCEL';
- if rbMB_ABORTRETRYIGNORE.Checked and rb_IDRETRY.Checked then ShieldButton := 'IDRETRY';
- if rbMB_ABORTRETRYIGNORE.Checked and rb_IDABORT.Checked then ShieldButton := 'IDABORT';
- if rbMB_ABORTRETRYIGNORE.Checked and rb_IDIGNORE.Checked then ShieldButton := 'IDIGNORE';
- { Suppressible msg }
- if cb_Suppressible.Checked then ShieldButton := ShieldButton + SuppressibleDefault;
- CaptionOrInstructionAndText := TaskInstructionText.Text + ''', ''' + TaskMessageText.Text;
- end;
- var IDButton, IDButton2, IDButton3: String;
- var Text: String;
- { selected button OK }
- if (cb_IDOK.Checked and not cb_IDCANCEL.Checked) then begin
- IDButton := 'IDOK';
- ButtonCount := 1;
- case ModeMsg of
- 0: Text := TextMsgBox(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, IDButton, '', '');
- 1: Text := TextTaskDialog(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, ButtonLabels, ShieldButton, IDButton, '', '');
- end;
- end
- { selected button CANCEL }
- else if (cb_IDCANCEL.Checked and not cb_IDOK.Checked and not cb_IDRETRY.Checked and not cb_IDYES.Checked and not cb_IDNO.Checked and not cb_IDABORT.Checked and not cb_IDIGNORE.Checked) then begin
- IDButton := 'IDCANCEL';
- ButtonCount := 1;
- case ModeMsg of
- 0: Text := TextMsgBox(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, IDButton, '', '');
- 1: Text := TextTaskDialog(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, ButtonLabels, ShieldButton, IDButton, '', '');
- end;
- end
- { selected button OK and CANCEL }
- else if (cb_IDCANCEL.Checked and cb_IDOK.Checked and not cb_IDRETRY.Checked and not cb_IDYES.Checked and not cb_IDNO.Checked) then begin
- IDButton := 'IDOK';
- IDButton2 := 'IDCANCEL';
- ButtonCount := 2;
- case ModeMsg of
- 0: Text := TextMsgBox(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, IDButton, IDButton2, '');
- 1: Text := TextTaskDialog(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, ButtonLabels, ShieldButton, IDButton, IDButton2, '');
- end;
- end
- { selected button YES }
- else if (cb_IDYES.Checked and not cb_IDNO.Checked and not cb_IDCANCEL.Checked) then begin
- IDButton := 'IDYES';
- ButtonCount := 1;
- case ModeMsg of
- 0: Text := TextMsgBox(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, IDButton, '', '');
- 1: Text := TextTaskDialog(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, ButtonLabels, ShieldButton, IDButton, '', '');
- end;
- end
- { selected button NO }
- else if (cb_IDNO.Checked and not cb_IDYES.Checked and not cb_IDCANCEL.Checked) then begin
- IDButton := 'IDNO';
- ButtonCount := 1;
- case ModeMsg of
- 0: Text := TextMsgBox(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, IDButton, '', '');
- 1: Text := TextTaskDialog(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, ButtonLabels, ShieldButton, IDButton, '', '');
- end;
- end
- { selected button YES and NO }
- else if (cb_IDYES.Checked and cb_IDNO.Checked and not cb_IDCANCEL.Checked) then begin
- IDButton := 'IDYES';
- IDButton2 := 'IDNO';
- ButtonCount := 2;
- case ModeMsg of
- 0: Text := TextMsgBox(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, IDButton, IDButton2, '');
- 1: Text := TextTaskDialog(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, ButtonLabels, ShieldButton, IDButton, IDButton2, '');
- end;
- end
- { selected button YES and CANCEL }
- else if (cb_IDYES.Checked and not cb_IDNO.Checked and cb_IDCANCEL.Checked) then begin
- IDButton := 'IDYES';
- IDButton2 := 'IDCANCEL';
- ButtonCount := 2;
- case ModeMsg of
- 0: Text := TextMsgBox(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, IDButton, IDButton2, '');
- 1: Text := TextTaskDialog(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, ButtonLabels, ShieldButton, IDButton, IDButton2, '');
- end;
- end
- { selected button NO and CANCEL }
- else if (cb_IDNO.Checked and not cb_IDYES.Checked and cb_IDCANCEL.Checked) then begin
- IDButton := 'IDNO';
- IDButton2 := 'IDCANCEL';
- ButtonCount := 2;
- case ModeMsg of
- 0: Text := TextMsgBox(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, IDButton, IDButton2, '');
- 1: Text := TextTaskDialog(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, ButtonLabels, ShieldButton, IDButton, IDButton2, '');
- end;
- end
- { selected button YES, NO and CANCEL }
- else if (cb_IDYES.Checked and cb_IDNO.Checked and cb_IDCANCEL.Checked) then begin
- IDButton := 'IDYES';
- IDButton2 := 'IDNO';
- IDButton3 := 'IDCANCEL';
- ButtonCount := 3;
- case ModeMsg of
- 0: Text := TextMsgBox(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, IDButton, IDButton2, IDButton3);
- 1: Text := TextTaskDialog(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, ButtonLabels, ShieldButton, IDButton, IDButton2, IDButton3);
- end;
- end
- { selected button RETRY }
- else if (cb_IDRETRY.Checked and not cb_IDCANCEL.Checked and not cb_IDABORT.Checked and not cb_IDIGNORE.Checked) then begin
- IDButton := 'IDRETRY';
- ButtonCount := 1;
- case ModeMsg of
- 0: Text := TextMsgBox(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, IDButton, '', '');
- 1: Text := TextTaskDialog(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, ButtonLabels, ShieldButton, IDButton, '', '');
- end;
- end
- { selected button RETRY and CANCEL }
- else if (cb_IDRETRY.Checked and cb_IDCANCEL.Checked and not cb_IDABORT.Checked and not cb_IDIGNORE.Checked) then begin
- IDButton := 'IDRETRY';
- IDButton2 := 'IDCANCEL';
- ButtonCount := 2;
- case ModeMsg of
- 0: Text := TextMsgBox(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, IDButton, IDButton2, '');
- 1: Text := TextTaskDialog(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, ButtonLabels, ShieldButton, IDButton, IDButton2, '');
- end;
- end
- { selected button IGNORE }
- else if (cb_IDIGNORE.Checked and not cb_IDCANCEL.Checked and not cb_IDABORT.Checked and not cb_IDRETRY.Checked) then begin
- IDButton := 'IDIGNORE';
- ButtonCount := 1;
- case ModeMsg of
- 0: Text := TextMsgBox(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, IDButton, '', '');
- 1: Text := TextTaskDialog(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, ButtonLabels, ShieldButton, IDButton, '', '');
- end;
- end
- { selected button ABORT }
- else if (cb_IDABORT.Checked and not cb_IDCANCEL.Checked and not cb_IDRETRY.Checked and not cb_IDIGNORE.Checked) then begin
- IDButton := 'IDABORT';
- ButtonCount := 1;
- case ModeMsg of
- 0: Text := TextMsgBox(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, IDButton, '', '');
- 1: Text := TextTaskDialog(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, ButtonLabels, ShieldButton, IDButton, '', '');
- end;
- end
- { selected button RETRY and IGNORE }
- else if (cb_IDRETRY.Checked and not cb_IDCANCEL.Checked and not cb_IDABORT.Checked and cb_IDIGNORE.Checked) then begin
- IDButton := 'IDRETRY';
- IDButton2 := 'IDIGNORE';
- ButtonCount := 2;
- case ModeMsg of
- 0: Text := TextMsgBox(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, IDButton, IDButton2, '');
- 1: Text := TextTaskDialog(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, ButtonLabels, ShieldButton, IDButton, IDButton2, '');
- end;
- end
- { selected button RETRY and ABORT }
- else if (cb_IDRETRY.Checked and not cb_IDCANCEL.Checked and cb_IDABORT.Checked and not cb_IDIGNORE.Checked) then begin
- IDButton := 'IDRETRY';
- IDButton2 := 'IDABORT';
- ButtonCount := 2;
- case ModeMsg of
- 0: Text := TextMsgBox(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, IDButton, IDButton2, '');
- 1: Text := TextTaskDialog(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, ButtonLabels, ShieldButton, IDButton, IDButton2, '');
- end;
- end
- { selected button IGNORE and ABORT }
- else if (not cb_IDRETRY.Checked and not cb_IDCANCEL.Checked and cb_IDABORT.Checked and cb_IDIGNORE.Checked) then begin
- IDButton := 'IDIGNORE';
- IDButton2 := 'IDABORT';
- ButtonCount := 2;
- case ModeMsg of
- 0: Text := TextMsgBox(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, IDButton, IDButton2, '');
- 1: Text := TextTaskDialog(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, ButtonLabels, ShieldButton, IDButton, IDButton2, '');
- end;
- end
- { selected button RETRY, IGNORE and ABORT }
- else if (cb_IDRETRY.Checked and not cb_IDCANCEL.Checked and cb_IDABORT.Checked and cb_IDIGNORE.Checked) then begin
- IDButton := 'IDRETRY';
- IDButton2 := 'IDIGNORE';
- IDButton3 := 'IDABORT';
- ButtonCount := 3;
- case ModeMsg of
- 0: Text := TextMsgBox(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, IDButton, IDButton2, IDButton3);
- 1: Text := TextTaskDialog(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, ButtonLabels, ShieldButton, IDButton, IDButton2, IDButton3);
- end;
- end
- { no selected buttons }
- else begin
- case ModeMsg of
- 0: Text := TextMsgBox(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, '', '', '');
- 1: Text := TextTaskDialog(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, ButtonLabels, ShieldButton, '', '', '');
- end;
- end;
- var SL := TStringList.Create;
- try
- SL.Text := Text;
- SL.Insert(0, '// Display a message box');
- for var I := 0 to SL.Count-1 do
- SL[I] := TextTab + SL[I];
- Result := SL.Text;
- finally
- SL.Free;
- end;
- end;
- end.
|