| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241 |
- 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;
- Button1Label: TNewStaticText;
- Button2Label: 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);
- 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;
- Button1Label.Visible := False;
- Button2Label.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;
- Button2Text.Enabled := False;
- Button2Label.Enabled := False;
- Button1Text.Enabled := True;
- Button1Label.Enabled := True;
- Button1Text.Text := 'OK';
- Button2Text.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;
- Button2Text.Enabled := True;
- Button2Label.Enabled := True;
- Button1Text.Enabled := True;
- Button1Label.Enabled := True;
- Button1Text.Text := 'Yes';
- Button2Text.Text := 'No';
- 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;
- Button2Text.Enabled := False;
- Button2Label.Enabled := False;
- Button1Text.Enabled := True;
- Button1Label.Enabled := True;
- Button1Text.Text := 'OK';
- Button2Text.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;
- Button2Text.Enabled := False;
- Button2Label.Enabled := False;
- Button1Text.Enabled := True;
- Button1Label.Enabled := True;
- Button1Text.Text := 'Retry';
- Button2Text.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;
- Button2Text.Enabled := True;
- Button2Label.Enabled := True;
- Button1Text.Enabled := True;
- Button1Label.Enabled := True;
- Button1Text.Text := 'Yes';
- Button2Text.Text := 'No';
- 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;
- Button2Text.Enabled := False;
- Button2Label.Enabled := False;
- Button1Text.Enabled := False;
- Button1Label.Enabled := False;
- Button1Text.Text := '';
- Button2Text.Text := '';
- 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;
- Button1Label.Visible := False;
- Button2Label.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;
- Button1Label.Visible := True;
- Button2Label.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 }
- var ButtonLabels: TArray<string>;
- if rbMB_YESNO.Checked or rbMB_YESNOCANCEL.Checked then
- ButtonLabels := TArray<string>.Create(Button1Text.Text, Button2Text.Text)
- else if rbMB_ABORTRETRYIGNORE.Checked then
- ButtonLabels := TArray<string>.Create('Retry', 'Ignore', 'Abort')
- else
- ButtonLabels := TArray<string>.Create(Button1Text.Text);
- { 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 }
- if rbMB_YESNO.Checked or rbMB_YESNOCANCEL.Checked then
- ButtonLabels := Button1Text.Text + ''', ''' + Button2Text.Text
- else if rbMB_ABORTRETRYIGNORE.Checked then
- ButtonLabels := 'Retry'', ''Ignore'', ''Abort'
- else
- ButtonLabels := Button1Text.Text;
- { 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.
|