IDE.MsgBoxDesignerForm.pas 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241
  1. unit IDE.MsgBoxDesignerForm;
  2. {
  3. Inno Setup
  4. Copyright (C) 1997-2024 Jordan Russell
  5. Portions by Martijn Laan
  6. For conditions of distribution and use, see LICENSE.TXT.
  7. MessageBox Designer form
  8. Originally contributed by leserg73
  9. }
  10. interface
  11. uses
  12. Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  13. UIStateForm, StdCtrls, ExtCtrls, NewStaticText, ComCtrls, pngimage;
  14. type
  15. TMsgBoxDesignerForm = class(TUIStateForm)
  16. IMGmbInformation: TImage;
  17. IMGmbConfirmation: TImage;
  18. IMGmbError: TImage;
  19. IMGmbCriticalError: TImage;
  20. Panel1: TPanel;
  21. GroupBox1: TGroupBox;
  22. GroupBox2: TGroupBox;
  23. MSGText: TMemo;
  24. rb_mbInformation: TRadioButton;
  25. rb_mbConfirmation: TRadioButton;
  26. rb_mbError: TRadioButton;
  27. rb_mbCriticalError: TRadioButton;
  28. GroupBox3: TGroupBox;
  29. MBDButtonOK: TButton;
  30. MBDButtonCancel: TButton;
  31. MBDButtonPreview: TButton;
  32. Bevel1: TBevel;
  33. rbMB_OK: TRadioButton;
  34. rbMB_OKCANCEL: TRadioButton;
  35. rbMB_YESNO: TRadioButton;
  36. rbMB_YESNOCANCEL: TRadioButton;
  37. rbMB_RETRYCANCEL: TRadioButton;
  38. rbMB_ABORTRETRYIGNORE: TRadioButton;
  39. GroupBox4: TGroupBox;
  40. cb_IDOK: TCheckBox;
  41. cb_IDCANCEL: TCheckBox;
  42. cb_IDYES: TCheckBox;
  43. cb_IDNO: TCheckBox;
  44. cb_IDABORT: TCheckBox;
  45. cb_IDRETRY: TCheckBox;
  46. cb_IDIGNORE: TCheckBox;
  47. GroupBox5: TGroupBox;
  48. cb_MB_SETFOREGROUND: TCheckBox;
  49. NewStaticText1: TNewStaticText;
  50. NewEdit1: TEdit;
  51. UpDown1: TUpDown;
  52. GroupBox6: TGroupBox;
  53. cb_MsgBox: TRadioButton;
  54. cb_TaskDialogMsgBox: TRadioButton;
  55. rb_IDOK: TCheckBox;
  56. rb_IDCANCEL: TCheckBox;
  57. rb_IDYES: TCheckBox;
  58. rb_IDNO: TCheckBox;
  59. rb_IDABORT: TCheckBox;
  60. rb_IDRETRY: TCheckBox;
  61. rb_IDIGNORE: TCheckBox;
  62. TaskInstructionLabel: TNewStaticText;
  63. TaskMessageLabel: TNewStaticText;
  64. TaskInstructionText: TEdit;
  65. TaskMessageText: TEdit;
  66. Button1Text: TEdit;
  67. Button2Text: TEdit;
  68. Button1Label: TNewStaticText;
  69. Button2Label: TNewStaticText;
  70. cb_Suppressible: TCheckBox;
  71. cb_DefIDOK: TRadioButton;
  72. cb_DefIDCANCEL: TRadioButton;
  73. cb_DefIDYES: TRadioButton;
  74. cb_DefIDNO: TRadioButton;
  75. cb_DefIDABORT: TRadioButton;
  76. cb_DefIDRETRY: TRadioButton;
  77. cb_DefIDIGNORE: TRadioButton;
  78. procedure FormCreate(Sender: TObject);
  79. procedure UpDown1Changing(Sender: TObject; var AllowChange: Boolean);
  80. procedure rbMB_OKClick(Sender: TObject);
  81. procedure rbMB_OKCANCELClick(Sender: TObject);
  82. procedure rbMB_YESNOClick(Sender: TObject);
  83. procedure rbMB_RETRYCANCELClick(Sender: TObject);
  84. procedure rbMB_YESNOCANCELClick(Sender: TObject);
  85. procedure rbMB_ABORTRETRYIGNOREClick(Sender: TObject);
  86. procedure MBDButtonPreviewClick(Sender: TObject);
  87. procedure cb_TaskDialogMsgBoxClick(Sender: TObject);
  88. procedure cb_MsgBoxClick(Sender: TObject);
  89. procedure rb_IDOKClick(Sender: TObject);
  90. procedure rb_IDCANCELClick(Sender: TObject);
  91. procedure rb_IDNOClick(Sender: TObject);
  92. procedure rb_IDYESClick(Sender: TObject);
  93. procedure rb_IDRETRYClick(Sender: TObject);
  94. procedure rb_IDIGNOREClick(Sender: TObject);
  95. procedure rb_IDABORTClick(Sender: TObject);
  96. procedure cb_SuppressibleClick(Sender: TObject);
  97. procedure MSGTextKeyPress(Sender: TObject; var Key: Char);
  98. public
  99. function GetText(TabWidth: Integer; UseTabCharacter: Boolean): String;
  100. end;
  101. implementation
  102. uses
  103. Shared.CommonFunc.Vcl, Shared.CommonFunc, IDE.HelperFunc, Shared.TaskDialogFunc, IDE.Messages;
  104. {$R *.DFM}
  105. procedure TMsgBoxDesignerForm.FormCreate(Sender: TObject);
  106. begin
  107. InitFormFont(Self);
  108. cb_Suppressible.Checked := True;
  109. MSGText.Lines[MSGText.CaretPos.Y] := '<Enter your text here...>';
  110. MSGText.SelStart := MSGText.Perform(EM_LINEINDEX, 0, 0);
  111. MSGText.SelLength := Length(MSGText.Lines[0]);
  112. cb_IDCANCEL.Enabled := False;
  113. cb_IDABORT.Enabled := False;
  114. cb_IDRETRY.Enabled := False;
  115. cb_IDIGNORE.Enabled := False;
  116. cb_IDYES.Enabled := False;
  117. cb_IDNO.Enabled := False;
  118. NewStaticText1.Enabled := False;
  119. NewEdit1.Enabled := False;
  120. UpDown1.Enabled := False;
  121. TaskInstructionLabel.Visible := False;
  122. TaskMessageLabel.Visible := False;
  123. TaskInstructionText.Visible := False;
  124. TaskMessageText.Visible := False;
  125. Button1Text.Visible := False;
  126. Button2Text.Visible := False;
  127. Button1Label.Visible := False;
  128. Button2Label.Visible := False;
  129. end;
  130. procedure TMsgBoxDesignerForm.rbMB_OKClick(Sender: TObject);
  131. begin
  132. cb_IDOK.Checked := False;
  133. cb_IDCANCEL.Checked := False;
  134. cb_IDABORT.Checked := False;
  135. cb_IDRETRY.Checked := False;
  136. cb_IDIGNORE.Checked := False;
  137. cb_IDYES.Checked := False;
  138. cb_IDNO.Checked := False;
  139. cb_IDOK.Enabled := False;
  140. cb_IDCANCEL.Enabled := False;
  141. cb_IDABORT.Enabled := False;
  142. cb_IDRETRY.Enabled := False;
  143. cb_IDIGNORE.Enabled := False;
  144. cb_IDYES.Enabled := False;
  145. cb_IDNO.Enabled := False;
  146. NewStaticText1.Enabled := False;
  147. NewEdit1.Enabled := False;
  148. NewEdit1.Text := '1';
  149. UpDown1.Enabled := False;
  150. if cb_TaskDialogMsgBox.Checked then begin
  151. rb_IDOK.Enabled := True;
  152. rb_IDCANCEL.Enabled := False;
  153. rb_IDABORT.Enabled := False;
  154. rb_IDRETRY.Enabled := False;
  155. rb_IDIGNORE.Enabled := False;
  156. rb_IDYES.Enabled := False;
  157. rb_IDNO.Enabled := False;
  158. rb_IDOK.Checked := False;
  159. rb_IDCANCEL.Checked := False;
  160. rb_IDABORT.Checked := False;
  161. rb_IDRETRY.Checked := False;
  162. rb_IDIGNORE.Checked := False;
  163. rb_IDYES.Checked := False;
  164. rb_IDNO.Checked := False;
  165. Button2Text.Enabled := False;
  166. Button2Label.Enabled := False;
  167. Button1Text.Enabled := True;
  168. Button1Label.Enabled := True;
  169. Button1Text.Text := 'OK';
  170. Button2Text.Text := '';
  171. end;
  172. if cb_Suppressible.Checked then begin
  173. cb_DefIDOK.Checked := True;
  174. cb_DefIDCANCEL.Checked := False;
  175. cb_DefIDYES.Checked := False;
  176. cb_DefIDNO.Checked := False;
  177. cb_DefIDABORT.Checked := False;
  178. cb_DefIDRETRY.Checked := False;
  179. cb_DefIDIGNORE.Checked := False;
  180. cb_DefIDOK.Enabled := True;
  181. cb_DefIDCANCEL.Enabled := False;
  182. cb_DefIDYES.Enabled := False;
  183. cb_DefIDNO.Enabled := False;
  184. cb_DefIDABORT.Enabled := False;
  185. cb_DefIDRETRY.Enabled := False;
  186. cb_DefIDIGNORE.Enabled := False;
  187. end;
  188. end;
  189. procedure TMsgBoxDesignerForm.rbMB_YESNOClick(Sender: TObject);
  190. begin
  191. cb_IDOK.Checked := False;
  192. cb_IDCANCEL.Checked := False;
  193. cb_IDABORT.Checked := False;
  194. cb_IDRETRY.Checked := False;
  195. cb_IDIGNORE.Checked := False;
  196. cb_IDYES.Checked := False;
  197. cb_IDNO.Checked := False;
  198. cb_IDOK.Enabled := False;
  199. cb_IDCANCEL.Enabled := False;
  200. cb_IDABORT.Enabled := False;
  201. cb_IDRETRY.Enabled := False;
  202. cb_IDIGNORE.Enabled := False;
  203. cb_IDYES.Enabled := True;
  204. cb_IDNO.Enabled := True;
  205. if not cb_TaskDialogMsgBox.Checked then begin
  206. NewStaticText1.Enabled := True;
  207. NewEdit1.Enabled := True;
  208. NewEdit1.Text := '1';
  209. UpDown1.Max := 2;
  210. UpDown1.Enabled := True;
  211. end;
  212. if cb_TaskDialogMsgBox.Checked then begin
  213. rb_IDOK.Enabled := False;
  214. rb_IDCANCEL.Enabled := False;
  215. rb_IDABORT.Enabled := False;
  216. rb_IDRETRY.Enabled := False;
  217. rb_IDIGNORE.Enabled := False;
  218. rb_IDYES.Enabled := True;
  219. rb_IDNO.Enabled := True;
  220. rb_IDOK.Checked := False;
  221. rb_IDCANCEL.Checked := False;
  222. rb_IDABORT.Checked := False;
  223. rb_IDRETRY.Checked := False;
  224. rb_IDIGNORE.Checked := False;
  225. rb_IDYES.Checked := False;
  226. rb_IDNO.Checked := False;
  227. Button2Text.Enabled := True;
  228. Button2Label.Enabled := True;
  229. Button1Text.Enabled := True;
  230. Button1Label.Enabled := True;
  231. Button1Text.Text := 'Yes';
  232. Button2Text.Text := 'No';
  233. end;
  234. if cb_Suppressible.Checked then begin
  235. cb_DefIDOK.Checked := False;
  236. cb_DefIDCANCEL.Checked := False;
  237. cb_DefIDYES.Checked := True;
  238. cb_DefIDNO.Checked := False;
  239. cb_DefIDABORT.Checked := False;
  240. cb_DefIDRETRY.Checked := False;
  241. cb_DefIDIGNORE.Checked := False;
  242. cb_DefIDOK.Enabled := False;
  243. cb_DefIDCANCEL.Enabled := False;
  244. cb_DefIDYES.Enabled := True;
  245. cb_DefIDNO.Enabled := True;
  246. cb_DefIDABORT.Enabled := False;
  247. cb_DefIDRETRY.Enabled := False;
  248. cb_DefIDIGNORE.Enabled := False;
  249. end;
  250. end;
  251. procedure TMsgBoxDesignerForm.rbMB_OKCANCELClick(Sender: TObject);
  252. begin
  253. cb_IDOK.Checked := False;
  254. cb_IDCANCEL.Checked := False;
  255. cb_IDABORT.Checked := False;
  256. cb_IDRETRY.Checked := False;
  257. cb_IDIGNORE.Checked := False;
  258. cb_IDYES.Checked := False;
  259. cb_IDNO.Checked := False;
  260. cb_IDOK.Enabled := True;
  261. cb_IDCANCEL.Enabled := True;
  262. cb_IDABORT.Enabled := False;
  263. cb_IDRETRY.Enabled := False;
  264. cb_IDIGNORE.Enabled := False;
  265. cb_IDYES.Enabled := False;
  266. cb_IDNO.Enabled := False;
  267. if not cb_TaskDialogMsgBox.Checked then begin
  268. NewStaticText1.Enabled := True;
  269. NewEdit1.Enabled := True;
  270. NewEdit1.Text := '1';
  271. UpDown1.Max := 2;
  272. UpDown1.Enabled := True;
  273. end;
  274. if cb_TaskDialogMsgBox.Checked then begin
  275. rb_IDOK.Enabled := True;
  276. rb_IDCANCEL.Enabled := True;
  277. rb_IDABORT.Enabled := False;
  278. rb_IDRETRY.Enabled := False;
  279. rb_IDIGNORE.Enabled := False;
  280. rb_IDYES.Enabled := False;
  281. rb_IDNO.Enabled := False;
  282. rb_IDOK.Checked := False;
  283. rb_IDCANCEL.Checked := False;
  284. rb_IDABORT.Checked := False;
  285. rb_IDRETRY.Checked := False;
  286. rb_IDIGNORE.Checked := False;
  287. rb_IDYES.Checked := False;
  288. rb_IDNO.Checked := False;
  289. Button2Text.Enabled := False;
  290. Button2Label.Enabled := False;
  291. Button1Text.Enabled := True;
  292. Button1Label.Enabled := True;
  293. Button1Text.Text := 'OK';
  294. Button2Text.Text := '';
  295. end;
  296. if cb_Suppressible.Checked then begin
  297. cb_DefIDOK.Checked := True;
  298. cb_DefIDCANCEL.Checked := False;
  299. cb_DefIDYES.Checked := False;
  300. cb_DefIDNO.Checked := False;
  301. cb_DefIDABORT.Checked := False;
  302. cb_DefIDRETRY.Checked := False;
  303. cb_DefIDIGNORE.Checked := False;
  304. cb_DefIDOK.Enabled := True;
  305. cb_DefIDCANCEL.Enabled := True;
  306. cb_DefIDYES.Enabled := False;
  307. cb_DefIDNO.Enabled := False;
  308. cb_DefIDABORT.Enabled := False;
  309. cb_DefIDRETRY.Enabled := False;
  310. cb_DefIDIGNORE.Enabled := False;
  311. end;
  312. end;
  313. procedure TMsgBoxDesignerForm.rbMB_RETRYCANCELClick(Sender: TObject);
  314. begin
  315. cb_IDOK.Checked := False;
  316. cb_IDCANCEL.Checked := False;
  317. cb_IDABORT.Checked := False;
  318. cb_IDRETRY.Checked := False;
  319. cb_IDIGNORE.Checked := False;
  320. cb_IDYES.Checked := False;
  321. cb_IDNO.Checked := False;
  322. cb_IDOK.Enabled := False;
  323. cb_IDCANCEL.Enabled := True;
  324. cb_IDABORT.Enabled := False;
  325. cb_IDRETRY.Enabled := True;
  326. cb_IDIGNORE.Enabled := False;
  327. cb_IDYES.Enabled := False;
  328. cb_IDNO.Enabled := False;
  329. if not cb_TaskDialogMsgBox.Checked then begin
  330. NewStaticText1.Enabled := True;
  331. NewEdit1.Enabled := True;
  332. NewEdit1.Text := '1';
  333. UpDown1.Max := 2;
  334. UpDown1.Enabled := True;
  335. end;
  336. if cb_TaskDialogMsgBox.Checked then begin
  337. rb_IDOK.Enabled := False;
  338. rb_IDCANCEL.Enabled := True;
  339. rb_IDABORT.Enabled := False;
  340. rb_IDRETRY.Enabled := True;
  341. rb_IDIGNORE.Enabled := False;
  342. rb_IDYES.Enabled := False;
  343. rb_IDNO.Enabled := False;
  344. rb_IDOK.Checked := False;
  345. rb_IDCANCEL.Checked := False;
  346. rb_IDABORT.Checked := False;
  347. rb_IDRETRY.Checked := False;
  348. rb_IDIGNORE.Checked := False;
  349. rb_IDYES.Checked := False;
  350. rb_IDNO.Checked := False;
  351. Button2Text.Enabled := False;
  352. Button2Label.Enabled := False;
  353. Button1Text.Enabled := True;
  354. Button1Label.Enabled := True;
  355. Button1Text.Text := 'Retry';
  356. Button2Text.Text := '';
  357. end;
  358. if cb_Suppressible.Checked then begin
  359. cb_DefIDOK.Checked := False;
  360. cb_DefIDCANCEL.Checked := True;
  361. cb_DefIDYES.Checked := False;
  362. cb_DefIDNO.Checked := False;
  363. cb_DefIDABORT.Checked := False;
  364. cb_DefIDRETRY.Checked := False;
  365. cb_DefIDIGNORE.Checked := False;
  366. cb_DefIDOK.Enabled := False;
  367. cb_DefIDCANCEL.Enabled := True;
  368. cb_DefIDYES.Enabled := False;
  369. cb_DefIDNO.Enabled := False;
  370. cb_DefIDABORT.Enabled := False;
  371. cb_DefIDRETRY.Enabled := True;
  372. cb_DefIDIGNORE.Enabled := False;
  373. end;
  374. end;
  375. procedure TMsgBoxDesignerForm.rbMB_YESNOCANCELClick(Sender: TObject);
  376. begin
  377. cb_IDOK.Checked := False;
  378. cb_IDCANCEL.Checked := False;
  379. cb_IDABORT.Checked := False;
  380. cb_IDRETRY.Checked := False;
  381. cb_IDIGNORE.Checked := False;
  382. cb_IDYES.Checked := False;
  383. cb_IDNO.Checked := False;
  384. cb_IDOK.Enabled := False;
  385. cb_IDCANCEL.Enabled := True;
  386. cb_IDABORT.Enabled := False;
  387. cb_IDRETRY.Enabled := False;
  388. cb_IDIGNORE.Enabled := False;
  389. cb_IDYES.Enabled := True;
  390. cb_IDNO.Enabled := True;
  391. if not cb_TaskDialogMsgBox.Checked then begin
  392. NewStaticText1.Enabled := True;
  393. NewEdit1.Enabled := True;
  394. NewEdit1.Text := '1';
  395. UpDown1.Max := 3;
  396. UpDown1.Enabled := True;
  397. end;
  398. if cb_TaskDialogMsgBox.Checked then begin
  399. rb_IDOK.Enabled := False;
  400. rb_IDCANCEL.Enabled := True;
  401. rb_IDABORT.Enabled := False;
  402. rb_IDRETRY.Enabled := False;
  403. rb_IDIGNORE.Enabled := False;
  404. rb_IDYES.Enabled := True;
  405. rb_IDNO.Enabled := True;
  406. rb_IDOK.Checked := False;
  407. rb_IDCANCEL.Checked := False;
  408. rb_IDABORT.Checked := False;
  409. rb_IDRETRY.Checked := False;
  410. rb_IDIGNORE.Checked := False;
  411. rb_IDYES.Checked := False;
  412. rb_IDNO.Checked := False;
  413. Button2Text.Enabled := True;
  414. Button2Label.Enabled := True;
  415. Button1Text.Enabled := True;
  416. Button1Label.Enabled := True;
  417. Button1Text.Text := 'Yes';
  418. Button2Text.Text := 'No';
  419. end;
  420. if cb_Suppressible.Checked then begin
  421. cb_DefIDOK.Checked := False;
  422. cb_DefIDCANCEL.Checked := False;
  423. cb_DefIDYES.Checked := True;
  424. cb_DefIDNO.Checked := False;
  425. cb_DefIDABORT.Checked := False;
  426. cb_DefIDRETRY.Checked := False;
  427. cb_DefIDIGNORE.Checked := False;
  428. cb_DefIDOK.Enabled := False;
  429. cb_DefIDCANCEL.Enabled := True;
  430. cb_DefIDYES.Enabled := True;
  431. cb_DefIDNO.Enabled := True;
  432. cb_DefIDABORT.Enabled := False;
  433. cb_DefIDRETRY.Enabled := False;
  434. cb_DefIDIGNORE.Enabled := False;
  435. end;
  436. end;
  437. procedure TMsgBoxDesignerForm.rbMB_ABORTRETRYIGNOREClick(Sender: TObject);
  438. begin
  439. cb_IDOK.Checked := False;
  440. cb_IDCANCEL.Checked := False;
  441. cb_IDABORT.Checked := False;
  442. cb_IDRETRY.Checked := False;
  443. cb_IDIGNORE.Checked := False;
  444. cb_IDYES.Checked := False;
  445. cb_IDNO.Checked := False;
  446. cb_IDOK.Enabled := False;
  447. cb_IDCANCEL.Enabled := False;
  448. cb_IDABORT.Enabled := True;
  449. cb_IDRETRY.Enabled := True;
  450. cb_IDIGNORE.Enabled := True;
  451. cb_IDYES.Enabled := False;
  452. cb_IDNO.Enabled := False;
  453. if not cb_TaskDialogMsgBox.Checked then begin
  454. NewStaticText1.Enabled := True;
  455. NewEdit1.Enabled := True;
  456. NewEdit1.Text := '1';
  457. UpDown1.Max := 3;
  458. UpDown1.Enabled := True;
  459. end;
  460. if cb_TaskDialogMsgBox.Checked then begin
  461. rb_IDOK.Enabled := False;
  462. rb_IDCANCEL.Enabled := False;
  463. rb_IDABORT.Enabled := True;
  464. rb_IDRETRY.Enabled := True;
  465. rb_IDIGNORE.Enabled := True;
  466. rb_IDYES.Enabled := False;
  467. rb_IDNO.Enabled := False;
  468. rb_IDOK.Checked := False;
  469. rb_IDCANCEL.Checked := False;
  470. rb_IDABORT.Checked := False;
  471. rb_IDRETRY.Checked := False;
  472. rb_IDIGNORE.Checked := False;
  473. rb_IDYES.Checked := False;
  474. rb_IDNO.Checked := False;
  475. Button2Text.Enabled := False;
  476. Button2Label.Enabled := False;
  477. Button1Text.Enabled := False;
  478. Button1Label.Enabled := False;
  479. Button1Text.Text := '';
  480. Button2Text.Text := '';
  481. end;
  482. if cb_Suppressible.Checked then begin
  483. cb_DefIDOK.Checked := False;
  484. cb_DefIDCANCEL.Checked := False;
  485. cb_DefIDYES.Checked := False;
  486. cb_DefIDNO.Checked := False;
  487. cb_DefIDABORT.Checked := False;
  488. cb_DefIDRETRY.Checked := False;
  489. cb_DefIDIGNORE.Checked := True;
  490. cb_DefIDOK.Enabled := False;
  491. cb_DefIDCANCEL.Enabled := False;
  492. cb_DefIDYES.Enabled := False;
  493. cb_DefIDNO.Enabled := False;
  494. cb_DefIDABORT.Enabled := True;
  495. cb_DefIDRETRY.Enabled := True;
  496. cb_DefIDIGNORE.Enabled := True;
  497. end;
  498. end;
  499. procedure TMsgBoxDesignerForm.UpDown1Changing(Sender: TObject; var AllowChange: Boolean);
  500. begin
  501. AllowChange := True;
  502. end;
  503. procedure TMsgBoxDesignerForm.cb_MsgBoxClick(Sender: TObject);
  504. begin
  505. IMGmbConfirmation.Visible := True;
  506. cb_MB_SETFOREGROUND.Enabled := True;
  507. cb_MB_SETFOREGROUND.Checked := False;
  508. GroupBox1.Visible := True;
  509. if not cb_Suppressible.Checked then begin
  510. GroupBox4.Caption := ' Return values ';
  511. cb_DefIDOK.Visible := False;
  512. cb_DefIDCANCEL.Visible := False;
  513. cb_DefIDYES.Visible := False;
  514. cb_DefIDNO.Visible := False;
  515. cb_DefIDABORT.Visible := False;
  516. cb_DefIDRETRY.Visible := False;
  517. cb_DefIDIGNORE.Visible := False;
  518. end
  519. else begin
  520. GroupBox4.Caption := ' Return values / -------- / Default ';
  521. cb_DefIDOK.Visible := True;
  522. cb_DefIDCANCEL.Visible := True;
  523. cb_DefIDYES.Visible := True;
  524. cb_DefIDNO.Visible := True;
  525. cb_DefIDABORT.Visible := True;
  526. cb_DefIDRETRY.Visible := True;
  527. cb_DefIDIGNORE.Visible := True;
  528. end;
  529. cb_IDOK.Checked := False;
  530. cb_IDCANCEL.Checked := False;
  531. cb_IDABORT.Checked := False;
  532. cb_IDRETRY.Checked := False;
  533. cb_IDIGNORE.Checked := False;
  534. cb_IDYES.Checked := False;
  535. cb_IDNO.Checked := False;
  536. rb_IDOK.Visible := False;
  537. rb_IDCANCEL.Visible := False;
  538. rb_IDABORT.Visible := False;
  539. rb_IDRETRY.Visible := False;
  540. rb_IDIGNORE.Visible := False;
  541. rb_IDYES.Visible := False;
  542. rb_IDNO.Visible := False;
  543. rb_mbInformation.Checked := True;
  544. TaskInstructionLabel.Visible := False;
  545. TaskMessageLabel.Visible := False;
  546. TaskInstructionText.Visible := False;
  547. TaskMessageText.Visible := False;
  548. Button1Text.Visible := False;
  549. Button2Text.Visible := False;
  550. Button1Label.Visible := False;
  551. Button2Label.Visible := False;
  552. rbMB_OK.Checked := True;
  553. rbMB_OKClick(Self);
  554. end;
  555. procedure TMsgBoxDesignerForm.cb_SuppressibleClick(Sender: TObject);
  556. begin
  557. if cb_Suppressible.Checked then begin
  558. cb_DefIDOK.Visible := True;
  559. cb_DefIDCANCEL.Visible := True;
  560. cb_DefIDYES.Visible := True;
  561. cb_DefIDNO.Visible := True;
  562. cb_DefIDABORT.Visible := True;
  563. cb_DefIDRETRY.Visible := True;
  564. cb_DefIDIGNORE.Visible := True;
  565. if cb_MsgBox.Checked then
  566. GroupBox4.Caption := ' Return values / -------- / Default ';
  567. if cb_TaskDialogMsgBox.Checked then
  568. GroupBox4.Caption := ' Return values / Shield / Default ';
  569. end
  570. else begin
  571. cb_DefIDOK.Checked := False;
  572. cb_DefIDCANCEL.Checked := False;
  573. cb_DefIDYES.Checked := False;
  574. cb_DefIDNO.Checked := False;
  575. cb_DefIDABORT.Checked := False;
  576. cb_DefIDRETRY.Checked := False;
  577. cb_DefIDIGNORE.Checked := False;
  578. cb_DefIDOK.Visible := False;
  579. cb_DefIDCANCEL.Visible := False;
  580. cb_DefIDYES.Visible := False;
  581. cb_DefIDNO.Visible := False;
  582. cb_DefIDABORT.Visible := False;
  583. cb_DefIDRETRY.Visible := False;
  584. cb_DefIDIGNORE.Visible := False;
  585. if cb_MsgBox.Checked then
  586. GroupBox4.Caption := ' Return values ';
  587. if cb_TaskDialogMsgBox.Checked then
  588. GroupBox4.Caption := ' Return values / Shield ';
  589. end;
  590. if rbMB_OK.Checked then rbMB_OKClick(Self);
  591. if rbMB_OKCANCEL.Checked then rbMB_OKCANCELClick(Self);
  592. if rbMB_YESNO.Checked then rbMB_YESNOClick(Self);
  593. if rbMB_YESNOCANCEL.Checked then rbMB_YESNOCANCELClick(Self);
  594. if rbMB_RETRYCANCEL.Checked then rbMB_RETRYCANCELClick(Self);
  595. if rbMB_ABORTRETRYIGNORE.Checked then rbMB_ABORTRETRYIGNOREClick(Self);
  596. end;
  597. procedure TMsgBoxDesignerForm.cb_TaskDialogMsgBoxClick(Sender: TObject);
  598. begin
  599. IMGmbConfirmation.Visible := False;
  600. cb_MB_SETFOREGROUND.Enabled := False;
  601. cb_MB_SETFOREGROUND.Checked := False;
  602. GroupBox1.Visible := False;
  603. if not cb_Suppressible.Checked then begin
  604. GroupBox4.Caption := ' Return values / Shield ';
  605. cb_DefIDOK.Visible := False;
  606. cb_DefIDCANCEL.Visible := False;
  607. cb_DefIDYES.Visible := False;
  608. cb_DefIDNO.Visible := False;
  609. cb_DefIDABORT.Visible := False;
  610. cb_DefIDRETRY.Visible := False;
  611. cb_DefIDIGNORE.Visible := False;
  612. end
  613. else begin
  614. GroupBox4.Caption := ' Return values / Shield / Default ';
  615. cb_DefIDOK.Visible := True;
  616. cb_DefIDCANCEL.Visible := True;
  617. cb_DefIDYES.Visible := True;
  618. cb_DefIDNO.Visible := True;
  619. cb_DefIDABORT.Visible := True;
  620. cb_DefIDRETRY.Visible := True;
  621. cb_DefIDIGNORE.Visible := True;
  622. end;
  623. cb_IDOK.Checked := False;
  624. cb_IDCANCEL.Checked := False;
  625. cb_IDABORT.Checked := False;
  626. cb_IDRETRY.Checked := False;
  627. cb_IDIGNORE.Checked := False;
  628. cb_IDYES.Checked := False;
  629. cb_IDNO.Checked := False;
  630. rb_IDOK.Checked := False;
  631. rb_IDCANCEL.Checked := False;
  632. rb_IDABORT.Checked := False;
  633. rb_IDRETRY.Checked := False;
  634. rb_IDIGNORE.Checked := False;
  635. rb_IDYES.Checked := False;
  636. rb_IDNO.Checked := False;
  637. rb_IDOK.Visible := True;
  638. rb_IDCANCEL.Visible := True;
  639. rb_IDABORT.Visible := True;
  640. rb_IDRETRY.Visible := True;
  641. rb_IDIGNORE.Visible := True;
  642. rb_IDYES.Visible := True;
  643. rb_IDNO.Visible := True;
  644. rb_mbInformation.Checked := True;
  645. TaskInstructionLabel.Visible := True;
  646. TaskMessageLabel.Visible := True;
  647. TaskInstructionText.Visible := True;
  648. TaskMessageText.Visible := True;
  649. Button1Text.Visible := True;
  650. Button2Text.Visible := True;
  651. Button1Label.Visible := True;
  652. Button2Label.Visible := True;
  653. TaskInstructionText.Text := 'Instruction Text';
  654. TaskMessageText.Text := 'Message Text';
  655. rbMB_OK.Checked := True;
  656. rbMB_OKClick(Self);
  657. end;
  658. procedure TMsgBoxDesignerForm.rb_IDOKClick(Sender: TObject);
  659. begin
  660. if rb_IDOK.Checked then
  661. rb_IDCANCEL.Checked := False;
  662. end;
  663. procedure TMsgBoxDesignerForm.rb_IDCANCELClick(Sender: TObject);
  664. begin
  665. if rb_IDCANCEL.Checked then begin
  666. rb_IDOK.Checked := False;
  667. rb_IDNO.Checked := False;
  668. rb_IDYES.Checked := False;
  669. rb_IDRETRY.Checked := False;
  670. end;
  671. end;
  672. procedure TMsgBoxDesignerForm.rb_IDYESClick(Sender: TObject);
  673. begin
  674. if rb_IDYES.Checked then begin
  675. rb_IDNO.Checked := False;
  676. rb_IDCANCEL.Checked := False;
  677. end;
  678. end;
  679. procedure TMsgBoxDesignerForm.rb_IDNOClick(Sender: TObject);
  680. begin
  681. if rb_IDNO.Checked then begin
  682. rb_IDYES.Checked := False;
  683. rb_IDCANCEL.Checked := False;
  684. end;
  685. end;
  686. procedure TMsgBoxDesignerForm.rb_IDRETRYClick(Sender: TObject);
  687. begin
  688. if rb_IDRETRY.Checked then begin
  689. rb_IDCANCEL.Checked := False;
  690. rb_IDABORT.Checked := False;
  691. rb_IDIGNORE.Checked := False;
  692. end;
  693. end;
  694. procedure TMsgBoxDesignerForm.rb_IDIGNOREClick(Sender: TObject);
  695. begin
  696. if rb_IDIGNORE.Checked then begin
  697. rb_IDABORT.Checked := False;
  698. rb_IDRETRY.Checked := False;
  699. end;
  700. end;
  701. procedure TMsgBoxDesignerForm.rb_IDABORTClick(Sender: TObject);
  702. begin
  703. if rb_IDABORT.Checked then begin
  704. rb_IDIGNORE.Checked := False;
  705. rb_IDRETRY.Checked := False;
  706. end;
  707. end;
  708. procedure TMsgBoxDesignerForm.MBDButtonPreviewClick(Sender: TObject);
  709. begin
  710. { default value }
  711. var Buttons := MB_OK;
  712. var Typ := mbInformation;
  713. { icon and caption set }
  714. var Caption: String;
  715. if rb_mbInformation.Checked then begin
  716. Caption := 'Info';
  717. Typ := mbInformation;
  718. end;
  719. if rb_mbConfirmation.Checked then begin
  720. Caption := 'Confirm';
  721. Typ := mbConfirmation;
  722. end;
  723. if rb_mbError.Checked then begin
  724. Caption := 'Error';
  725. Typ := mbError;
  726. end;
  727. if rb_mbCriticalError.Checked then begin
  728. Caption := 'Fatal Error';
  729. Typ := mbCriticalError;
  730. end;
  731. { button type set }
  732. if rbMB_OK.Checked then Buttons := MB_OK;
  733. if rbMB_OKCANCEL.Checked then Buttons := MB_OKCANCEL;
  734. if rbMB_YESNO.Checked then Buttons := MB_YESNO;
  735. if rbMB_YESNOCANCEL.Checked then Buttons := MB_YESNOCANCEL;
  736. if rbMB_RETRYCANCEL.Checked then Buttons := MB_RETRYCANCEL;
  737. if rbMB_ABORTRETRYIGNORE.Checked then Buttons := MB_ABORTRETRYIGNORE;
  738. if cb_MsgBox.Checked then begin
  739. if MSGText.GetTextLen = 0 then
  740. MSGText.Lines.Add('Your message text.');
  741. { MessageBox with DefButton }
  742. if NewEdit1.Text = '1' then
  743. MsgBox(MSGText.Lines.GetText, Caption, Typ, Buttons);
  744. if NewEdit1.Text = '2' then
  745. MsgBox(MSGText.Lines.GetText, Caption, Typ, Buttons or MB_DEFBUTTON2);
  746. if NewEdit1.Text = '3' then
  747. MsgBox(MSGText.Lines.GetText, Caption, Typ, Buttons or MB_DEFBUTTON3);
  748. { MessageBox with DefButton and Flag MB_SETFOREGROUND }
  749. if (NewEdit1.Text = '1') and (cb_MB_SETFOREGROUND.Checked) then
  750. MsgBox(MSGText.Lines.GetText, Caption, Typ, Buttons or MB_SETFOREGROUND);
  751. if (NewEdit1.Text = '2') and (cb_MB_SETFOREGROUND.Checked) then
  752. MsgBox(MSGText.Lines.GetText, Caption, Typ, Buttons or MB_DEFBUTTON2 or MB_SETFOREGROUND);
  753. if (NewEdit1.Text = '3') and (cb_MB_SETFOREGROUND.Checked) then
  754. MsgBox(MSGText.Lines.GetText, Caption, Typ, Buttons or MB_DEFBUTTON3 or MB_SETFOREGROUND);
  755. end else if cb_TaskDialogMsgBox.Checked then begin
  756. { create ButtonLabels array }
  757. var ButtonLabels: TArray<string>;
  758. if rbMB_YESNO.Checked or rbMB_YESNOCANCEL.Checked then
  759. ButtonLabels := TArray<string>.Create(Button1Text.Text, Button2Text.Text)
  760. else if rbMB_ABORTRETRYIGNORE.Checked then
  761. ButtonLabels := TArray<string>.Create('Retry', 'Ignore', 'Abort')
  762. else
  763. ButtonLabels := TArray<string>.Create(Button1Text.Text);
  764. { get Shield Flag value }
  765. var ShieldButton := 0;
  766. if rbMB_OK.Checked and rb_IDOK.Checked then ShieldButton := IDOK;
  767. if rbMB_OKCANCEL.Checked and rb_IDOK.Checked then ShieldButton := IDOK;
  768. if rbMB_OKCANCEL.Checked and rb_IDCANCEL.Checked then ShieldButton := IDCANCEL;
  769. if rbMB_YESNO.Checked and rb_IDYES.Checked then ShieldButton := IDYES;
  770. if rbMB_YESNO.Checked and rb_IDNO.Checked then ShieldButton := IDNO;
  771. if rbMB_YESNOCANCEL.Checked and rb_IDYES.Checked then ShieldButton := IDYES;
  772. if rbMB_YESNOCANCEL.Checked and rb_IDNO.Checked then ShieldButton := IDNO;
  773. if rbMB_YESNOCANCEL.Checked and rb_IDCANCEL.Checked then ShieldButton := IDCANCEL;
  774. if rbMB_RETRYCANCEL.Checked and rb_IDRETRY.Checked then ShieldButton := IDRETRY;
  775. if rbMB_RETRYCANCEL.Checked and rb_IDCANCEL.Checked then ShieldButton := IDCANCEL;
  776. if rbMB_ABORTRETRYIGNORE.Checked and rb_IDRETRY.Checked then ShieldButton := IDRETRY;
  777. if rbMB_ABORTRETRYIGNORE.Checked and rb_IDABORT.Checked then ShieldButton := IDABORT;
  778. if rbMB_ABORTRETRYIGNORE.Checked and rb_IDIGNORE.Checked then ShieldButton := IDIGNORE;
  779. { TaskDialogMsgBox(Icon, Instruction, Text, Caption, Typ, Buttons, ButtonLabels, ShieldButton) }
  780. TaskDialogMsgBox('', TaskInstructionText.Text, TaskMessageText.Text, Caption,
  781. Typ, Buttons, ButtonLabels, ShieldButton);
  782. end;
  783. end;
  784. procedure TMsgBoxDesignerForm.MSGTextKeyPress(Sender: TObject; var Key: Char);
  785. begin
  786. if Key = #27 then begin
  787. MBDButtonCancel.Click;
  788. Key := #0;
  789. end;
  790. end;
  791. function TMsgBoxDesignerForm.GetText(TabWidth: Integer; UseTabCharacter: Boolean): String;
  792. function TextTab: String;
  793. begin
  794. if UseTabCharacter then
  795. Result := #9
  796. else
  797. Result := Format('%*s', [TabWidth, '']);
  798. end;
  799. function TextUserClicked(IDButton: String): String;
  800. begin
  801. Result := 'user clicked ' + StringReplace(IDButton, 'ID', '', [])
  802. end;
  803. function TextCase(IDButton: String): String;
  804. begin
  805. Result := TextTab + IDButton +': { ' + TextUserClicked(IDButton) + ' };';
  806. end;
  807. function TextCall(ButtonCount: Integer; SCall, IDButton, IDButton2, IDButton3: String): String;
  808. begin
  809. case ButtonCount of
  810. 0: Result := SCall + ';';
  811. 1: Result := 'if ' + SCall + ' = ' + IDButton + ' then' + SNewLine +
  812. 'begin' + SNewLine +
  813. TextTab + '// ' + TextUserClicked(IDButton) + SNewLine +
  814. 'end;';
  815. 2, 3:
  816. begin
  817. Result := 'case ' + SCall + ' of ' + SNewLine +
  818. TextCase(IDButton) + SNewLine +
  819. TextCase(IDButton2) + SNewLine;
  820. if ButtonCount = 3 then
  821. Result := Result + TextCase(IDButton3) + SNewLine;
  822. Result := Result + 'end;';
  823. end;
  824. end;
  825. end;
  826. { MsgBox / SuppressibleMsgBox }
  827. function TextMsgBox(ButtonCount: Integer; Caption, Typ, Buttons,
  828. IDButton, IDButton2, IDButton3: String): String;
  829. begin
  830. var SMsgBox: String;
  831. if not cb_Suppressible.Checked then
  832. SMsgBox := 'MsgBox'
  833. else
  834. SMsgBox := 'SuppressibleMsgBox';
  835. //Buttons also contains Default if suppressible, pre-separated by a comma (but ButtonCount does *not* include this)
  836. SMsgBox := SMsgBox + '(''' + Caption + ''', ' + Typ + ', ' + Buttons + ')';
  837. Result := TextCall(ButtonCount, SMsgBox, IDButton, IDButton2, IDButton3);
  838. end;
  839. { TaskDialogMsgBox / SuppressibleTaskDialogMsgBox }
  840. function TextTaskDialog(ButtonCount: Integer; InstructionAndText, Typ, Buttons,
  841. ButtonLabels, ShieldButton, IDButton, IDButton2, IDButton3: String): String;
  842. begin
  843. var STaskDialog: String;
  844. if not cb_Suppressible.Checked then
  845. STaskDialog := 'TaskDialogMsgBox'
  846. else
  847. STaskDialog := 'SuppressibleTaskDialogMsgBox';
  848. //InstructionAndText contains both Instruction and Text, pre-separated by a quote, a comma and another quote
  849. //ButtonLabels contains all labels, also pre-separated by the above
  850. //ShieldButton also contains Default if suppressible, pre-separated by a comma (but ButtonCount does *not* include this)
  851. STaskDialog := STaskDialog+ '(''' + InstructionAndText + ''', ' + Typ + ', ' + Buttons + ', [''' + ButtonLabels + '''], ' + ShieldButton + ')';
  852. Result := TextCall(ButtonCount, STaskDialog, IDButton, IDButton2, IDButton3);
  853. end;
  854. begin
  855. { default value }
  856. var ButtonCount := 0;
  857. var Buttons := 'MB_OK';
  858. var Typ := 'mbInformation';
  859. var ShieldButton: String := '0';
  860. var SuppressibleDefault := '';
  861. { make a string with Default parameter for Suppressible* calls }
  862. if cb_Suppressible.Checked then begin
  863. if cb_DefIDOK.Checked then SuppressibleDefault := ', IDOK';
  864. if cb_DefIDCANCEL.Checked then SuppressibleDefault := ', IDCANCEL';
  865. if cb_DefIDYES.Checked then SuppressibleDefault := ', IDYES';
  866. if cb_DefIDNO.Checked then SuppressibleDefault := ', IDNO';
  867. if cb_DefIDABORT.Checked then SuppressibleDefault := ', IDABORT';
  868. if cb_DefIDRETRY.Checked then SuppressibleDefault := ', IDRETRY';
  869. if cb_DefIDIGNORE.Checked then SuppressibleDefault := ', IDIGNORE';
  870. end;
  871. { icon and caption set }
  872. if rb_mbInformation.Checked then begin
  873. Typ := 'mbInformation';
  874. end;
  875. if rb_mbConfirmation.Checked then begin
  876. Typ := 'mbConfirmation';
  877. end;
  878. if rb_mbError.Checked then begin
  879. Typ := 'mbError';
  880. end;
  881. if rb_mbCriticalError.Checked then begin
  882. Typ := 'mbCriticalError';
  883. end;
  884. { button type set }
  885. if rbMB_OK.Checked then Buttons := 'MB_OK';
  886. if rbMB_OKCANCEL.Checked then Buttons := 'MB_OKCANCEL';
  887. if rbMB_YESNO.Checked then Buttons := 'MB_YESNO';
  888. if rbMB_YESNOCANCEL.Checked then Buttons := 'MB_YESNOCANCEL';
  889. if rbMB_RETRYCANCEL.Checked then Buttons := 'MB_RETRYCANCEL';
  890. if rbMB_ABORTRETRYIGNORE.Checked then Buttons := 'MB_ABORTRETRYIGNORE';
  891. var ModeMsg: Integer;
  892. var CaptionOrInstructionAndText: String;
  893. var ButtonLabels: String;
  894. if cb_MsgBox.Checked then begin
  895. { MsgBox(Text, Typ, Buttons); }
  896. ModeMsg := 0;
  897. { MessageBox with DefButton and Flag MB_SETFOREGROUND }
  898. if (rbMB_OK.Checked) and (cb_MB_SETFOREGROUND.Checked) then
  899. Buttons := 'MB_OK or MB_SETFOREGROUND';
  900. if (rbMB_OKCANCEL.Checked) and (NewEdit1.Text = '2') then
  901. Buttons := 'MB_OKCANCEL or MB_DEFBUTTON2';
  902. { MessageBox with DefButton and Flag MB_SETFOREGROUND }
  903. if (rbMB_OKCANCEL.Checked) and (cb_MB_SETFOREGROUND.Checked) then
  904. Buttons := 'MB_OKCANCEL or MB_SETFOREGROUND';
  905. if (rbMB_OKCANCEL.Checked) and (NewEdit1.Text = '2') and (cb_MB_SETFOREGROUND.Checked) then
  906. Buttons := 'MB_OKCANCEL or MB_DEFBUTTON2 or MB_SETFOREGROUND';
  907. if (rbMB_YESNO.Checked) and (NewEdit1.Text = '2') then
  908. Buttons := 'MB_YESNO or MB_DEFBUTTON2';
  909. { MessageBox with DefButton and Flag MB_SETFOREGROUND }
  910. if (rbMB_YESNO.Checked) and (cb_MB_SETFOREGROUND.Checked) then
  911. Buttons := 'MB_YESNO or MB_SETFOREGROUND';
  912. if (rbMB_YESNO.Checked) and (NewEdit1.Text = '2') and (cb_MB_SETFOREGROUND.Checked) then
  913. Buttons := 'MB_YESNO or MB_DEFBUTTON2 or MB_SETFOREGROUND';
  914. if (rbMB_RETRYCANCEL.Checked) and (NewEdit1.Text = '2') then
  915. Buttons := 'MB_RETRYCANCEL or MB_DEFBUTTON2';
  916. { MessageBox with DefButton and Flag MB_SETFOREGROUND }
  917. if (rbMB_RETRYCANCEL.Checked) and (cb_MB_SETFOREGROUND.Checked) then
  918. Buttons := 'MB_RETRYCANCEL or MB_SETFOREGROUND';
  919. if (rbMB_RETRYCANCEL.Checked) and (NewEdit1.Text = '2') and (cb_MB_SETFOREGROUND.Checked) then
  920. Buttons := 'MB_RETRYCANCEL or MB_DEFBUTTON2 or MB_SETFOREGROUND';
  921. if (rbMB_YESNOCANCEL.Checked) and (NewEdit1.Text = '2') then
  922. Buttons := 'MB_YESNOCANCEL or MB_DEFBUTTON2';
  923. if (rbMB_YESNOCANCEL.Checked) and (NewEdit1.Text = '3') then
  924. Buttons := 'MB_YESNOCANCEL or MB_DEFBUTTON3';
  925. { MessageBox with DefButton and Flag MB_SETFOREGROUND }
  926. if (rbMB_YESNOCANCEL.Checked) and (cb_MB_SETFOREGROUND.Checked) then
  927. Buttons := 'MB_YESNOCANCEL or MB_SETFOREGROUND';
  928. if (rbMB_YESNOCANCEL.Checked) and (NewEdit1.Text = '2') and (cb_MB_SETFOREGROUND.Checked) then
  929. Buttons := 'MB_YESNOCANCEL or MB_DEFBUTTON2 or MB_SETFOREGROUND';
  930. if (rbMB_YESNOCANCEL.Checked) and (NewEdit1.Text = '3') and (cb_MB_SETFOREGROUND.Checked) then
  931. Buttons := 'MB_YESNOCANCEL or MB_DEFBUTTON3 or MB_SETFOREGROUND';
  932. if (rbMB_ABORTRETRYIGNORE.Checked) and (NewEdit1.Text = '2') then
  933. Buttons := 'MB_ABORTRETRYIGNORE or MB_DEFBUTTON2';
  934. if (rbMB_ABORTRETRYIGNORE.Checked) and (NewEdit1.Text = '3') then
  935. Buttons := 'MB_ABORTRETRYIGNORE or MB_DEFBUTTON3';
  936. { MessageBox with DefButton and Flag MB_SETFOREGROUND }
  937. if (rbMB_ABORTRETRYIGNORE.Checked) and (cb_MB_SETFOREGROUND.Checked) then
  938. Buttons := 'MB_ABORTRETRYIGNORE or MB_SETFOREGROUND';
  939. if (rbMB_ABORTRETRYIGNORE.Checked) and (NewEdit1.Text = '2') and (cb_MB_SETFOREGROUND.Checked) then
  940. Buttons := 'MB_ABORTRETRYIGNORE or MB_DEFBUTTON2 or MB_SETFOREGROUND';
  941. if (rbMB_ABORTRETRYIGNORE.Checked) and (NewEdit1.Text = '3') and (cb_MB_SETFOREGROUND.Checked) then
  942. Buttons := 'MB_ABORTRETRYIGNORE or MB_DEFBUTTON3 or MB_SETFOREGROUND';
  943. { Suppressible msg }
  944. if cb_Suppressible.Checked then Buttons := Buttons + SuppressibleDefault;
  945. { replace in a message string escape /r/n }
  946. CaptionOrInstructionAndText := StringReplace(MSGText.Lines.GetText, SNewLine, '''#13#10''', [rfReplaceAll]);
  947. end else begin
  948. { TaskDialogMsgBox(TaskInstructionText.Text, TaskMessageText.Text, Typ, Buttons, ButtonLabels, ShieldButton) }
  949. ModeMsg := 1;
  950. { create ButtonLabels array }
  951. if rbMB_YESNO.Checked or rbMB_YESNOCANCEL.Checked then
  952. ButtonLabels := Button1Text.Text + ''', ''' + Button2Text.Text
  953. else if rbMB_ABORTRETRYIGNORE.Checked then
  954. ButtonLabels := 'Retry'', ''Ignore'', ''Abort'
  955. else
  956. ButtonLabels := Button1Text.Text;
  957. { get Shield Flag value }
  958. if rbMB_OK.Checked and rb_IDOK.Checked then ShieldButton := 'IDOK';
  959. if rbMB_OKCANCEL.Checked and rb_IDOK.Checked then ShieldButton := 'IDOK';
  960. if rbMB_OKCANCEL.Checked and rb_IDCANCEL.Checked then ShieldButton := 'IDCANCEL';
  961. if rbMB_YESNO.Checked and rb_IDYES.Checked then ShieldButton := 'IDYES';
  962. if rbMB_YESNO.Checked and rb_IDNO.Checked then ShieldButton := 'IDNO';
  963. if rbMB_YESNOCANCEL.Checked and rb_IDYES.Checked then ShieldButton := 'IDYES';
  964. if rbMB_YESNOCANCEL.Checked and rb_IDNO.Checked then ShieldButton := 'IDNO';
  965. if rbMB_YESNOCANCEL.Checked and rb_IDCANCEL.Checked then ShieldButton := 'IDCANCEL';
  966. if rbMB_RETRYCANCEL.Checked and rb_IDRETRY.Checked then ShieldButton := 'IDRETRY';
  967. if rbMB_RETRYCANCEL.Checked and rb_IDCANCEL.Checked then ShieldButton := 'IDCANCEL';
  968. if rbMB_ABORTRETRYIGNORE.Checked and rb_IDRETRY.Checked then ShieldButton := 'IDRETRY';
  969. if rbMB_ABORTRETRYIGNORE.Checked and rb_IDABORT.Checked then ShieldButton := 'IDABORT';
  970. if rbMB_ABORTRETRYIGNORE.Checked and rb_IDIGNORE.Checked then ShieldButton := 'IDIGNORE';
  971. { Suppressible msg }
  972. if cb_Suppressible.Checked then ShieldButton := ShieldButton + SuppressibleDefault;
  973. CaptionOrInstructionAndText := TaskInstructionText.Text + ''', ''' + TaskMessageText.Text;
  974. end;
  975. var IDButton, IDButton2, IDButton3: String;
  976. var Text: String;
  977. { selected button OK }
  978. if (cb_IDOK.Checked and not cb_IDCANCEL.Checked) then begin
  979. IDButton := 'IDOK';
  980. ButtonCount := 1;
  981. case ModeMsg of
  982. 0: Text := TextMsgBox(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, IDButton, '', '');
  983. 1: Text := TextTaskDialog(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, ButtonLabels, ShieldButton, IDButton, '', '');
  984. end;
  985. end
  986. { selected button CANCEL }
  987. 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
  988. IDButton := 'IDCANCEL';
  989. ButtonCount := 1;
  990. case ModeMsg of
  991. 0: Text := TextMsgBox(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, IDButton, '', '');
  992. 1: Text := TextTaskDialog(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, ButtonLabels, ShieldButton, IDButton, '', '');
  993. end;
  994. end
  995. { selected button OK and CANCEL }
  996. 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
  997. IDButton := 'IDOK';
  998. IDButton2 := 'IDCANCEL';
  999. ButtonCount := 2;
  1000. case ModeMsg of
  1001. 0: Text := TextMsgBox(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, IDButton, IDButton2, '');
  1002. 1: Text := TextTaskDialog(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, ButtonLabels, ShieldButton, IDButton, IDButton2, '');
  1003. end;
  1004. end
  1005. { selected button YES }
  1006. else if (cb_IDYES.Checked and not cb_IDNO.Checked and not cb_IDCANCEL.Checked) then begin
  1007. IDButton := 'IDYES';
  1008. ButtonCount := 1;
  1009. case ModeMsg of
  1010. 0: Text := TextMsgBox(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, IDButton, '', '');
  1011. 1: Text := TextTaskDialog(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, ButtonLabels, ShieldButton, IDButton, '', '');
  1012. end;
  1013. end
  1014. { selected button NO }
  1015. else if (cb_IDNO.Checked and not cb_IDYES.Checked and not cb_IDCANCEL.Checked) then begin
  1016. IDButton := 'IDNO';
  1017. ButtonCount := 1;
  1018. case ModeMsg of
  1019. 0: Text := TextMsgBox(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, IDButton, '', '');
  1020. 1: Text := TextTaskDialog(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, ButtonLabels, ShieldButton, IDButton, '', '');
  1021. end;
  1022. end
  1023. { selected button YES and NO }
  1024. else if (cb_IDYES.Checked and cb_IDNO.Checked and not cb_IDCANCEL.Checked) then begin
  1025. IDButton := 'IDYES';
  1026. IDButton2 := 'IDNO';
  1027. ButtonCount := 2;
  1028. case ModeMsg of
  1029. 0: Text := TextMsgBox(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, IDButton, IDButton2, '');
  1030. 1: Text := TextTaskDialog(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, ButtonLabels, ShieldButton, IDButton, IDButton2, '');
  1031. end;
  1032. end
  1033. { selected button YES and CANCEL }
  1034. else if (cb_IDYES.Checked and not cb_IDNO.Checked and cb_IDCANCEL.Checked) then begin
  1035. IDButton := 'IDYES';
  1036. IDButton2 := 'IDCANCEL';
  1037. ButtonCount := 2;
  1038. case ModeMsg of
  1039. 0: Text := TextMsgBox(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, IDButton, IDButton2, '');
  1040. 1: Text := TextTaskDialog(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, ButtonLabels, ShieldButton, IDButton, IDButton2, '');
  1041. end;
  1042. end
  1043. { selected button NO and CANCEL }
  1044. else if (cb_IDNO.Checked and not cb_IDYES.Checked and cb_IDCANCEL.Checked) then begin
  1045. IDButton := 'IDNO';
  1046. IDButton2 := 'IDCANCEL';
  1047. ButtonCount := 2;
  1048. case ModeMsg of
  1049. 0: Text := TextMsgBox(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, IDButton, IDButton2, '');
  1050. 1: Text := TextTaskDialog(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, ButtonLabels, ShieldButton, IDButton, IDButton2, '');
  1051. end;
  1052. end
  1053. { selected button YES, NO and CANCEL }
  1054. else if (cb_IDYES.Checked and cb_IDNO.Checked and cb_IDCANCEL.Checked) then begin
  1055. IDButton := 'IDYES';
  1056. IDButton2 := 'IDNO';
  1057. IDButton3 := 'IDCANCEL';
  1058. ButtonCount := 3;
  1059. case ModeMsg of
  1060. 0: Text := TextMsgBox(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, IDButton, IDButton2, IDButton3);
  1061. 1: Text := TextTaskDialog(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, ButtonLabels, ShieldButton, IDButton, IDButton2, IDButton3);
  1062. end;
  1063. end
  1064. { selected button RETRY }
  1065. else if (cb_IDRETRY.Checked and not cb_IDCANCEL.Checked and not cb_IDABORT.Checked and not cb_IDIGNORE.Checked) then begin
  1066. IDButton := 'IDRETRY';
  1067. ButtonCount := 1;
  1068. case ModeMsg of
  1069. 0: Text := TextMsgBox(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, IDButton, '', '');
  1070. 1: Text := TextTaskDialog(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, ButtonLabels, ShieldButton, IDButton, '', '');
  1071. end;
  1072. end
  1073. { selected button RETRY and CANCEL }
  1074. else if (cb_IDRETRY.Checked and cb_IDCANCEL.Checked and not cb_IDABORT.Checked and not cb_IDIGNORE.Checked) then begin
  1075. IDButton := 'IDRETRY';
  1076. IDButton2 := 'IDCANCEL';
  1077. ButtonCount := 2;
  1078. case ModeMsg of
  1079. 0: Text := TextMsgBox(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, IDButton, IDButton2, '');
  1080. 1: Text := TextTaskDialog(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, ButtonLabels, ShieldButton, IDButton, IDButton2, '');
  1081. end;
  1082. end
  1083. { selected button IGNORE }
  1084. else if (cb_IDIGNORE.Checked and not cb_IDCANCEL.Checked and not cb_IDABORT.Checked and not cb_IDRETRY.Checked) then begin
  1085. IDButton := 'IDIGNORE';
  1086. ButtonCount := 1;
  1087. case ModeMsg of
  1088. 0: Text := TextMsgBox(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, IDButton, '', '');
  1089. 1: Text := TextTaskDialog(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, ButtonLabels, ShieldButton, IDButton, '', '');
  1090. end;
  1091. end
  1092. { selected button ABORT }
  1093. else if (cb_IDABORT.Checked and not cb_IDCANCEL.Checked and not cb_IDRETRY.Checked and not cb_IDIGNORE.Checked) then begin
  1094. IDButton := 'IDABORT';
  1095. ButtonCount := 1;
  1096. case ModeMsg of
  1097. 0: Text := TextMsgBox(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, IDButton, '', '');
  1098. 1: Text := TextTaskDialog(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, ButtonLabels, ShieldButton, IDButton, '', '');
  1099. end;
  1100. end
  1101. { selected button RETRY and IGNORE }
  1102. else if (cb_IDRETRY.Checked and not cb_IDCANCEL.Checked and not cb_IDABORT.Checked and cb_IDIGNORE.Checked) then begin
  1103. IDButton := 'IDRETRY';
  1104. IDButton2 := 'IDIGNORE';
  1105. ButtonCount := 2;
  1106. case ModeMsg of
  1107. 0: Text := TextMsgBox(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, IDButton, IDButton2, '');
  1108. 1: Text := TextTaskDialog(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, ButtonLabels, ShieldButton, IDButton, IDButton2, '');
  1109. end;
  1110. end
  1111. { selected button RETRY and ABORT }
  1112. else if (cb_IDRETRY.Checked and not cb_IDCANCEL.Checked and cb_IDABORT.Checked and not cb_IDIGNORE.Checked) then begin
  1113. IDButton := 'IDRETRY';
  1114. IDButton2 := 'IDABORT';
  1115. ButtonCount := 2;
  1116. case ModeMsg of
  1117. 0: Text := TextMsgBox(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, IDButton, IDButton2, '');
  1118. 1: Text := TextTaskDialog(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, ButtonLabels, ShieldButton, IDButton, IDButton2, '');
  1119. end;
  1120. end
  1121. { selected button IGNORE and ABORT }
  1122. else if (not cb_IDRETRY.Checked and not cb_IDCANCEL.Checked and cb_IDABORT.Checked and cb_IDIGNORE.Checked) then begin
  1123. IDButton := 'IDIGNORE';
  1124. IDButton2 := 'IDABORT';
  1125. ButtonCount := 2;
  1126. case ModeMsg of
  1127. 0: Text := TextMsgBox(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, IDButton, IDButton2, '');
  1128. 1: Text := TextTaskDialog(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, ButtonLabels, ShieldButton, IDButton, IDButton2, '');
  1129. end;
  1130. end
  1131. { selected button RETRY, IGNORE and ABORT }
  1132. else if (cb_IDRETRY.Checked and not cb_IDCANCEL.Checked and cb_IDABORT.Checked and cb_IDIGNORE.Checked) then begin
  1133. IDButton := 'IDRETRY';
  1134. IDButton2 := 'IDIGNORE';
  1135. IDButton3 := 'IDABORT';
  1136. ButtonCount := 3;
  1137. case ModeMsg of
  1138. 0: Text := TextMsgBox(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, IDButton, IDButton2, IDButton3);
  1139. 1: Text := TextTaskDialog(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, ButtonLabels, ShieldButton, IDButton, IDButton2, IDButton3);
  1140. end;
  1141. end
  1142. { no selected buttons }
  1143. else begin
  1144. case ModeMsg of
  1145. 0: Text := TextMsgBox(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, '', '', '');
  1146. 1: Text := TextTaskDialog(ButtonCount, CaptionOrInstructionAndText, Typ, Buttons, ButtonLabels, ShieldButton, '', '', '');
  1147. end;
  1148. end;
  1149. var SL := TStringList.Create;
  1150. try
  1151. SL.Text := Text;
  1152. SL.Insert(0, '// Display a message box');
  1153. for var I := 0 to SL.Count-1 do
  1154. SL[I] := TextTab + SL[I];
  1155. Result := SL.Text;
  1156. finally
  1157. SL.Free;
  1158. end;
  1159. end;
  1160. end.