CodeClasses.iss 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. ; -- CodeClasses.iss --
  2. ;
  3. ; This script shows how to use the WizardForm object and the various VCL classes.
  4. [Setup]
  5. AppName=My Program
  6. AppVersion=1.5
  7. WizardStyle=modern dynamic
  8. CreateAppDir=no
  9. Uninstallable=no
  10. DisableProgramGroupPage=yes
  11. DefaultGroupName=My Program
  12. OutputDir=userdocs:Inno Setup Examples Output
  13. PrivilegesRequired=lowest
  14. ; Uncomment the following three lines to test the layout for RTL and scaling
  15. ;[LangOptions]
  16. ;RightToLeft=yes
  17. ;DialogFontSize=12
  18. [Files]
  19. Source: compiler:WizClassicSmallImage.bmp; Flags: dontcopy
  20. [Code]
  21. procedure ButtonOnClick(Sender: TObject);
  22. begin
  23. MsgBox('You clicked the button!', mbInformation, mb_Ok);
  24. end;
  25. procedure FormButtonOnClick(Sender: TObject);
  26. var
  27. Form: TSetupForm;
  28. Edit: TNewEdit;
  29. OKButton, CancelButton: TNewButton;
  30. W: Integer;
  31. begin
  32. { Keep the form from sizing vertically since we don't have any controls which can size vertically }
  33. Form := CreateCustomForm(ScaleX(256), ScaleY(128), False, True);
  34. try
  35. Form.Caption := 'TSetupForm';
  36. Edit := TNewEdit.Create(Form);
  37. Edit.Top := ScaleY(10);
  38. Edit.Left := ScaleX(10);
  39. Edit.Width := Form.ClientWidth - ScaleX(2 * 10);
  40. Edit.Height := ScaleY(23);
  41. Edit.Anchors := [akLeft, akTop, akRight];
  42. Edit.Text := 'TNewEdit';
  43. Edit.Parent := Form;
  44. OKButton := TNewButton.Create(Form);
  45. OKButton.Parent := Form;
  46. OKButton.Caption := 'OK';
  47. OKButton.Left := Form.ClientWidth - ScaleX(75 + 6 + 75 + 10);
  48. OKButton.Top := Form.ClientHeight - ScaleY(23 + 10);
  49. OKButton.Height := ScaleY(23);
  50. OKButton.Anchors := [akRight, akBottom];
  51. OKButton.ModalResult := mrOk;
  52. OKButton.Default := True;
  53. CancelButton := TNewButton.Create(Form);
  54. CancelButton.Parent := Form;
  55. CancelButton.Caption := 'Cancel';
  56. CancelButton.Left := Form.ClientWidth - ScaleX(75 + 10);
  57. CancelButton.Top := Form.ClientHeight - ScaleY(23 + 10);
  58. CancelButton.Height := ScaleY(23);
  59. CancelButton.Anchors := [akRight, akBottom];
  60. CancelButton.ModalResult := mrCancel;
  61. CancelButton.Cancel := True;
  62. W := Form.CalculateButtonWidth([OKButton.Caption, CancelButton.Caption]);
  63. OKButton.Width := W;
  64. CancelButton.Width := W;
  65. Form.ActiveControl := Edit;
  66. { Center on WizardForm. Without this call it will still automatically center, but on the screen }
  67. Form.FlipAndCenterIfNeeded(True, WizardForm, False);
  68. if Form.ShowModal() = mrOk then
  69. MsgBox('You clicked OK.', mbInformation, MB_OK);
  70. finally
  71. Form.Free();
  72. end;
  73. end;
  74. procedure TaskDialogButtonOnClick(Sender: TObject);
  75. begin
  76. { TaskDialogMsgBox isn't a class but showing it anyway since it fits with the theme }
  77. case TaskDialogMsgBox('Choose A or B',
  78. 'You can choose A or B.',
  79. mbInformation,
  80. MB_YESNOCANCEL, ['I choose &A'#13#10'A will be chosen.', 'I choose &B'#13#10'B will be chosen.'],
  81. IDYES) of
  82. IDYES: MsgBox('You chose A.', mbInformation, MB_OK);
  83. IDNO: MsgBox('You chose B.', mbInformation, MB_OK);
  84. end;
  85. end;
  86. procedure LinkLabelOnLinkClick(Sender: TObject; const Link: string; LinkType: TSysLinkType);
  87. var
  88. ErrorCode: Integer;
  89. begin
  90. if (LinkType = sltID) and (Link = 'jrsoftware') then
  91. ShellExecAsOriginalUser('open', 'https://jrsoftware.org', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode)
  92. else if LinkType = sltURL then
  93. ShellExecAsOriginalUser('open', Link, '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
  94. end;
  95. procedure CreateTheWizardPages;
  96. var
  97. Page: TWizardPage;
  98. Button, FormButton, TaskDialogButton, CommandLinkButton: TNewButton;
  99. Panel: TPanel;
  100. CheckBox: TNewCheckBox;
  101. Edit: TNewEdit;
  102. PasswordEdit: TPasswordEdit;
  103. Memo: TNewMemo;
  104. ComboBox: TNewComboBox;
  105. ListBox: TNewListBox;
  106. StaticText: array [0..2] of TNewStaticText;
  107. ProgressBarLabel: TNewStaticText;
  108. LinkLabel: TNewLinkLabel;
  109. ProgressBar: array [0..2] of TNewProgressBar;
  110. CheckListBox: array [0..1] of TNewCheckListBox;
  111. FolderTreeView: TFolderTreeView;
  112. BitmapImage: array [0..5] of TBitmapImage;
  113. Siids: array of Integer;
  114. SiidBitmapImage: TBitmapImage;
  115. I: Integer;
  116. BitmapButton: array [0..2] of TBitmapButton;
  117. BitmapFileName: String;
  118. RichEditViewer: TRichEditViewer;
  119. begin
  120. { TButton and others }
  121. Page := CreateCustomPage(wpWelcome, 'Custom wizard page controls', 'TButton and others');
  122. Button := TNewButton.Create(Page);
  123. Button.Caption := 'TNewButton';
  124. Button.Width := WizardForm.CalculateButtonWidth([Button.Caption]);
  125. Button.Height := ScaleY(23);
  126. Button.OnClick := @ButtonOnClick;
  127. Button.Parent := Page.Surface;
  128. Panel := TPanel.Create(Page);
  129. Panel.Width := Page.SurfaceWidth div 2 - ScaleX(8);
  130. Panel.Left := Page.SurfaceWidth - Panel.Width;
  131. Panel.Height := Button.Height * 2;
  132. Panel.Anchors := [akLeft, akTop, akRight];
  133. Panel.Caption := 'TPanel';
  134. Panel.Color := clWindow;
  135. Panel.BevelKind := bkFlat;
  136. Panel.BevelOuter := bvNone;
  137. Panel.ParentBackground := False;
  138. Panel.Parent := Page.Surface;
  139. CheckBox := TNewCheckBox.Create(Page);
  140. CheckBox.Top := Button.Top + Button.Height + ScaleY(8);
  141. CheckBox.Width := Page.SurfaceWidth div 2;
  142. CheckBox.Height := ScaleY(17);
  143. CheckBox.Caption := 'TNewCheckBox';
  144. CheckBox.Checked := True;
  145. CheckBox.Parent := Page.Surface;
  146. Edit := TNewEdit.Create(Page);
  147. Edit.Top := CheckBox.Top + CheckBox.Height + ScaleY(8);
  148. Edit.Width := Page.SurfaceWidth div 2 - ScaleX(8);
  149. Edit.Text := 'TNewEdit';
  150. Edit.Parent := Page.Surface;
  151. PasswordEdit := TPasswordEdit.Create(Page);
  152. PasswordEdit.Left := Page.SurfaceWidth - Edit.Width;
  153. PasswordEdit.Top := CheckBox.Top + CheckBox.Height + ScaleY(8);
  154. PasswordEdit.Width := Edit.Width;
  155. PasswordEdit.Anchors := [akLeft, akTop, akRight];
  156. PasswordEdit.Text := 'TPasswordEdit';
  157. PasswordEdit.Parent := Page.Surface;
  158. Memo := TNewMemo.Create(Page);
  159. Memo.Top := Edit.Top + Edit.Height + ScaleY(8);
  160. Memo.Width := Page.SurfaceWidth;
  161. Memo.Height := ScaleY(70);
  162. Memo.Anchors := [akLeft, akTop, akRight, akBottom];
  163. Memo.ScrollBars := ssVertical;
  164. Memo.Text := 'TNewMemo';
  165. Memo.Parent := Page.Surface;
  166. FormButton := TNewButton.Create(Page);
  167. FormButton.Caption := 'TSetupForm';
  168. FormButton.Top := Memo.Top + Memo.Height + ScaleY(8);
  169. FormButton.Width := WizardForm.CalculateButtonWidth([FormButton.Caption]);
  170. FormButton.Height := ScaleY(23);
  171. FormButton.Anchors := [akLeft, akBottom];
  172. FormButton.OnClick := @FormButtonOnClick;
  173. FormButton.Parent := Page.Surface;
  174. TaskDialogButton := TNewButton.Create(Page);
  175. TaskDialogButton.Caption := 'TaskDialogMsgBox';
  176. TaskDialogButton.Top := FormButton.Top + FormButton.Height + ScaleY(8);
  177. TaskDialogButton.Left := FormButton.Left;
  178. TaskDialogButton.Width := WizardForm.CalculateButtonWidth([TaskDialogButton.Caption]);
  179. TaskDialogButton.Height := ScaleY(23);
  180. TaskDialogButton.Anchors := [akLeft, akBottom];
  181. TaskDialogButton.OnClick := @TaskDialogButtonOnClick;
  182. TaskDialogButton.Parent := Page.Surface;
  183. CommandLinkButton := TNewButton.Create(Page);
  184. CommandLinkButton.Style := bsCommandLink;
  185. CommandLinkButton.Caption := 'TNewButton bsCommandLink';
  186. CommandLinkButton.CommandLinkHint := 'A note';
  187. //CommandLinkButton.ElevationRequired := True;
  188. CommandLinkButton.Font.Size := MulDiv(CommandLinkButton.Font.Size, 12, 9);
  189. CommandLinkButton.Top := FormButton.Top;
  190. CommandLinkButton.Left := TaskDialogButton.Left + TaskDialogButton.Width + ScaleX(8);
  191. CommandLinkButton.Width := Page.Surface.Width - CommandLinkButton.Left;
  192. CommandLinkButton.Anchors := [akLeft, akRight, akBottom];
  193. CommandLinkButton.OnClick := @ButtonOnClick;
  194. CommandLinkButton.Parent := Page.Surface;
  195. CommandLinkButton.AdjustHeightIfCommandLink;
  196. { TComboBox and others }
  197. Page := CreateCustomPage(Page.ID, 'Custom wizard page controls', 'TComboBox and others');
  198. ComboBox := TNewComboBox.Create(Page);
  199. ComboBox.Width := Page.SurfaceWidth;
  200. ComboBox.Anchors := [akLeft, akTop, akRight];
  201. ComboBox.Parent := Page.Surface;
  202. ComboBox.Style := csDropDownList;
  203. ComboBox.Items.Add('TComboBox');
  204. ComboBox.ItemIndex := 0;
  205. ListBox := TNewListBox.Create(Page);
  206. ListBox.Top := ComboBox.Top + ComboBox.Height + ScaleY(8);
  207. ListBox.Width := Page.SurfaceWidth;
  208. ListBox.Height := ScaleY(97);
  209. ListBox.Anchors := [akLeft, akTop, akRight, akBottom];
  210. ListBox.Parent := Page.Surface;
  211. ListBox.Items.Add('TListBox');
  212. ListBox.ItemIndex := 0;
  213. StaticText[0] := TNewStaticText.Create(Page);
  214. StaticText[0].Top := ListBox.Top + ListBox.Height + ScaleY(8);
  215. StaticText[0].Anchors := [akLeft, akBottom];
  216. StaticText[0].Caption := 'TNewStaticText';
  217. StaticText[0].Parent := Page.Surface;
  218. StaticText[1] := TNewStaticText.Create(Page);
  219. StaticText[1].AutoSize := False;
  220. StaticText[1].Left := StaticText[0].Width + ScaleX(32);
  221. StaticText[1].Top := StaticText[0].Top;
  222. StaticText[1].Anchors := [akLeft, akRight, akBottom];
  223. StaticText[1].WordWrap := True;
  224. StaticText[1].Caption := 'TNewStaticText with more text and an adjusted label height so it''s multi-line.';
  225. StaticText[1].Width := 2 * StaticText[0].Width;
  226. StaticText[1].Parent := Page.Surface;
  227. StaticText[1].AdjustHeight;
  228. StaticText[2] := TNewStaticText.Create(Page);
  229. StaticText[2].Top := StaticText[0].Top + StaticText[0].Height + ScaleY(8);
  230. StaticText[2].Anchors := [akLeft, akBottom];
  231. StaticText[2].Caption := 'TNewStaticText';
  232. StaticText[2].Parent := Page.Surface;
  233. StaticText[2].StyleElements := StaticText[2].StyleElements - [seFont];
  234. if IsDarkInstallMode then
  235. StaticText[2].Font.Color := StrToColor('#D95E6C')
  236. else
  237. StaticText[2].Font.Color := StrToColor('#D24152');
  238. LinkLabel := TNewLinkLabel.Create(Page);
  239. LinkLabel.AutoSize := False;
  240. LinkLabel.Left := StaticText[1].Left;
  241. LinkLabel.Top := StaticText[1].Top + StaticText[1].Height + ScaleY(8);
  242. LinkLabel.Anchors := [akLeft, akRight, akBottom];
  243. LinkLabel.Caption := 'TNew<a id="jrsoftware">Link</a>Label with more text and an adjusted label height so it''s multi-line with a second <a id="jrsoftware">link</a> on the second line.';
  244. LinkLabel.Width := StaticText[1].Width;
  245. LinkLabel.UseVisualStyle := HighContrastActive;
  246. LinkLabel.OnLinkClick := @LinkLabelOnLinkClick;
  247. LinkLabel.Parent := Page.Surface;
  248. LinkLabel.AdjustHeight;
  249. { TNewProgressBar }
  250. Page := CreateCustomPage(Page.ID, 'Custom wizard page controls', 'TNewProgressBar');
  251. ProgressBarLabel := TNewStaticText.Create(Page);
  252. ProgressBarLabel.Anchors := [akLeft, akTop];
  253. ProgressBarLabel.Caption := 'TNewProgressBar';
  254. ProgressBarLabel.Parent := Page.Surface;
  255. ProgressBar[0] := TNewProgressBar.Create(Page);
  256. ProgressBar[0].Left := ProgressBarLabel.Width + ScaleX(8);
  257. ProgressBar[0].Top := ProgressBarLabel.Top;
  258. ProgressBar[0].Width := Page.SurfaceWidth - ProgressBar[0].Left;
  259. ProgressBar[0].Height := ProgressBarLabel.Height + ScaleY(8);
  260. ProgressBar[0].Anchors := [akLeft, akRight, akTop];
  261. ProgressBar[0].Parent := Page.Surface;
  262. ProgressBar[0].Position := 25;
  263. ProgressBar[1] := TNewProgressBar.Create(Page);
  264. ProgressBar[1].Left := ProgressBarLabel.Width + ScaleX(8);
  265. ProgressBar[1].Top := ProgressBar[0].Top + ProgressBar[0].Height + ScaleY(4);
  266. ProgressBar[1].Width := Page.SurfaceWidth - ProgressBar[0].Left;
  267. ProgressBar[1].Height := ProgressBarLabel.Height + ScaleY(8);
  268. ProgressBar[1].Anchors := [akLeft, akRight, akTop];
  269. ProgressBar[1].Parent := Page.Surface;
  270. ProgressBar[1].Position := 50;
  271. ProgressBar[1].State := npbsError;
  272. ProgressBar[2] := TNewProgressBar.Create(Page);
  273. ProgressBar[2].Left := ProgressBarLabel.Width + ScaleX(8);
  274. ProgressBar[2].Top := ProgressBar[1].Top + ProgressBar[1].Height + ScaleY(4);
  275. ProgressBar[2].Width := Page.SurfaceWidth - ProgressBar[0].Left;
  276. ProgressBar[2].Height := ProgressBarLabel.Height + ScaleY(8);
  277. ProgressBar[2].Anchors := [akLeft, akRight, akTop];
  278. ProgressBar[2].Parent := Page.Surface;
  279. ProgressBar[2].Style := npbstMarquee;
  280. { TNewCheckListBox }
  281. Page := CreateCustomPage(Page.ID, 'Custom wizard page controls', 'TNewCheckListBox');
  282. CheckListBox[0] := TNewCheckListBox.Create(Page);
  283. CheckListBox[0].Width := Page.SurfaceWidth;
  284. CheckListBox[0].Height := ScaleY(97);
  285. CheckListBox[0].Anchors := [akLeft, akTop, akRight, akBottom];
  286. CheckListBox[0].Flat := True;
  287. CheckListBox[0].Parent := Page.Surface;
  288. CheckListBox[0].AddCheckBox('TNewCheckListBox', '', 0, True, True, False, True, nil);
  289. CheckListBox[0].AddRadioButton('TNewCheckListBox', '', 1, True, True, nil);
  290. CheckListBox[0].AddRadioButton('TNewCheckListBox', '', 1, False, True, nil);
  291. CheckListBox[0].AddCheckBox('TNewCheckListBox', '', 0, True, True, False, True, nil);
  292. CheckListBox[0].AddCheckBox('TNewCheckListBox', '', 1, True, True, False, True, nil);
  293. CheckListBox[0].AddCheckBox('TNewCheckListBox', '123', 2, True, True, False, True, nil);
  294. CheckListBox[0].AddCheckBox('TNewCheckListBox', '456', 2, False, True, False, True, nil);
  295. CheckListBox[0].AddCheckBox('TNewCheckListBox', '', 1, False, True, False, True, nil);
  296. CheckListBox[0].ItemFontStyle[5] := [fsBold];
  297. CheckListBox[0].SubItemFontStyle[5] := [fsBold];
  298. CheckListBox[0].ItemFontStyle[6] := [fsBold, fsItalic];
  299. CheckListBox[0].SubItemFontStyle[6] := [fsBold, fsUnderline];
  300. CheckListBox[1] := TNewCheckListBox.Create(Page);
  301. CheckListBox[1].Top := CheckListBox[0].Top + CheckListBox[0].Height + ScaleY(8);
  302. CheckListBox[1].Width := Page.SurfaceWidth;
  303. CheckListBox[1].Height := ScaleY(97);
  304. CheckListBox[1].Anchors := [akLeft, akRight, akBottom];
  305. CheckListBox[1].BorderStyle := bsNone;
  306. CheckListBox[1].ParentColor := True;
  307. CheckListBox[1].MinItemHeight := WizardForm.TasksList.MinItemHeight;
  308. CheckListBox[1].ShowLines := False;
  309. CheckListBox[1].WantTabs := True;
  310. CheckListBox[1].Parent := Page.Surface;
  311. CheckListBox[1].AddGroup('TNewCheckListBox', '', 0, nil);
  312. CheckListBox[1].AddRadioButton('TNewCheckListBox', '', 0, True, True, nil);
  313. CheckListBox[1].AddRadioButton('TNewCheckListBox', '', 0, False, True, nil);
  314. { TFolderTreeView }
  315. Page := CreateCustomPage(Page.ID, 'Custom wizard page controls', 'TFolderTreeView');
  316. FolderTreeView := TFolderTreeView.Create(Page);
  317. FolderTreeView.Width := Page.SurfaceWidth;
  318. FolderTreeView.Height := Page.SurfaceHeight;
  319. FolderTreeView.Anchors := [akLeft, akTop, akRight, akBottom];
  320. FolderTreeView.Parent := Page.Surface;
  321. FolderTreeView.Directory := ExpandConstant('{src}');
  322. { TBitmapImage }
  323. Page := CreateCustomPage(Page.ID, 'Custom wizard page controls', 'TBitmapImage');
  324. BitmapFileName := ExpandConstant('{tmp}\WizClassicSmallImage.bmp');
  325. ExtractTemporaryFile(ExtractFileName(BitmapFileName));
  326. BitmapImage[0] := TBitmapImage.Create(Page);
  327. BitmapImage[0].AutoSize := True;
  328. { Use BitmapImage[0].PngImage.LoadFromFile to load .png files }
  329. BitmapImage[0].Bitmap.LoadFromFile(BitmapFileName);
  330. BitmapImage[0].Parent := Page.Surface;
  331. BitmapImage[1] := TBitmapImage.Create(Page);
  332. BitmapImage[1].BackColor := clNone;
  333. BitmapImage[1].Bitmap := BitmapImage[0].Bitmap;
  334. BitmapImage[1].Center := True;
  335. BitmapImage[1].Left := BitmapImage[0].Width + 10;
  336. BitmapImage[1].Width := 2*BitmapImage[0].Width;
  337. BitmapImage[1].Height := 2*BitmapImage[0].Height;
  338. BitmapImage[1].Parent := Page.Surface;
  339. BitmapImage[2] := TBitmapImage.Create(Page);
  340. BitmapImage[2].Bitmap := BitmapImage[0].Bitmap;
  341. BitmapImage[2].Stretch := True;
  342. BitmapImage[2].Left := 3*BitmapImage[0].Width + 20;
  343. BitmapImage[2].Width := 4*BitmapImage[0].Width;
  344. BitmapImage[2].Height := 4*BitmapImage[0].Height;
  345. BitmapImage[2].Anchors := [akLeft, akTop, akRight, akBottom];
  346. BitmapImage[2].Parent := Page.Surface;
  347. Page := CreateCustomPage(Page.ID, 'Custom wizard page controls', 'TBitmapImage (stock icons)');
  348. BitmapImage[3] := TBitmapImage.Create(Page);
  349. BitmapImage[3].Width := ScaleX(16);
  350. BitmapImage[3].Height := BitmapImage[3].Width;
  351. InitializeBitmapImageFromStockIcon(BitmapImage[3], SIID_ERROR, clNone, [16, 24, 32]);
  352. BitmapImage[3].Parent := Page.Surface;
  353. BitmapImage[4] := TBitmapImage.Create(Page);
  354. BitmapImage[4].Width := ScaleX(32);
  355. BitmapImage[4].Height := BitmapImage[4].Width;
  356. InitializeBitmapImageFromStockIcon(BitmapImage[4], SIID_ERROR, clNone, [32, 48, 64]);
  357. BitmapImage[4].Left := BitmapImage[3].Left + BitmapImage[3].Width + 10;
  358. BitmapImage[4].Parent := Page.Surface;
  359. BitmapImage[5] := TBitmapImage.Create(Page);
  360. BitmapImage[5].Width := 256;
  361. BitmapImage[5].Height := BitmapImage[5].Width;
  362. InitializeBitmapImageFromStockIcon(BitmapImage[5], SIID_ERROR, clNone, []);
  363. BitmapImage[5].Top := BitmapImage[4].Top + BitmapImage[4].Height + 10;
  364. BitmapImage[5].Parent := Page.Surface;
  365. { See https://learn.microsoft.com/en-us/windows/win32/api/shellapi/ne-shellapi-shstockiconid for all available icons }
  366. Siids := [
  367. SIID_INFO, SIID_HELP, SIID_WARNING, SIID_LOCK, SIID_KEY,
  368. SIID_DOCNOASSOC, SIID_DOCASSOC, SIID_AUDIOFILES, SIID_IMAGEFILES, SIID_VIDEOFILES,
  369. SIID_APPLICATION, SIID_SOFTWARE, SIID_FOLDER, SIID_ZIPFILE, SIID_SHIELD,
  370. SIID_SERVER, SIID_MYNETWORK, SIID_DEVICECELLPHONE, SIID_DRIVEREMOVE, SIID_PRINTER,
  371. SIID_FIND, SIID_MEDIACDAUDIO, SIID_MEDIABLANKCD, SIID_RENAME, SIID_DELETE];
  372. for I := 0 to High(Siids) do begin
  373. SiidBitmapImage := TBitmapImage.Create(Page);
  374. SiidBitmapImage.Width := ScaleX(32);
  375. SiidBitmapImage.Height := SiidBitmapImage.Width;
  376. InitializeBitmapImageFromStockIcon(SiidBitmapImage, Siids[I], clNone, [32, 48, 64]);
  377. SiidBitmapImage.Left := BitmapImage[5].Left + BitmapImage[5].Width + 20 + (I mod 5) * ScaleX(42);
  378. SiidBitmapImage.Top := (I div 5) * ScaleY(42);
  379. SiidBitmapImage.Parent := Page.Surface;
  380. end;
  381. { TBitmapButton - Always has a 2 pixel margin around the image, used to
  382. display a focus rectangle. Other changes compared to TBitmapImage are:
  383. • Has a Caption property which should always be set
  384. • Center defaults to True
  385. • BackColor defaults to clNone }
  386. Page := CreateCustomPage(Page.ID, 'Custom wizard page controls', 'TBitmapButton (Press Alt to see focus rectangle)');
  387. BitmapButton[0] := TBitmapButton.Create(Page);
  388. BitmapButton[0].AutoSize := True;
  389. BitmapButton[0].Bitmap := BitmapImage[0].Bitmap;
  390. BitmapButton[0].Caption := 'Show Message'; { For accessibility }
  391. BitmapButton[0].Hint := 'TBitmapButton is an accessible version of TBitmapImage';
  392. BitmapButton[0].ShowHint := True;
  393. BitmapButton[0].Width := 2*BitmapButton[0].Width;
  394. BitmapButton[0].Cursor := crHand;
  395. BitmapButton[0].OnClick := @ButtonOnClick;
  396. BitmapButton[0].Parent := Page.Surface;
  397. BitmapButton[1] := TBitmapButton.Create(Page);
  398. BitmapButton[1].BackColor := $400000;
  399. BitmapButton[1].Bitmap := BitmapImage[0].Bitmap;
  400. BitmapButton[1].Caption := BitmapButton[0].Caption;
  401. BitmapButton[1].Hint := BitmapButton[0].Hint;
  402. BitmapButton[1].ShowHint := True;
  403. BitmapButton[1].Left := BitmapButton[0].Width + 10;
  404. BitmapButton[1].Width := 2*BitmapButton[0].Width;
  405. BitmapButton[1].Height := 2*BitmapButton[0].Height;
  406. BitmapButton[1].Cursor := crHand;
  407. BitmapButton[1].OnClick := @ButtonOnClick;
  408. BitmapButton[1].Parent := Page.Surface;
  409. BitmapButton[2] := TBitmapButton.Create(Page);
  410. BitmapButton[2].Width := ScaleX(24);
  411. BitmapButton[2].Height := ScaleY(24);
  412. InitializeBitmapButtonFromStockIcon(BitmapButton[2], SIID_HELP, clNone, [24, 36, 38]);
  413. BitmapButton[2].Caption := BitmapButton[0].Caption;
  414. BitmapButton[2].Hint := BitmapButton[0].Hint;
  415. BitmapButton[2].ShowHint := True;
  416. BitmapButton[2].Left := BitmapButton[1].Left + BitmapButton[1].Width + 10;
  417. BitmapButton[2].Cursor := crHand;
  418. BitmapButton[2].OnClick := @ButtonOnClick;
  419. BitmapButton[2].Parent := Page.Surface;
  420. { TRichViewer }
  421. Page := CreateCustomPage(Page.ID, 'Custom wizard page controls', 'TRichViewer');
  422. RichEditViewer := TRichEditViewer.Create(Page);
  423. RichEditViewer.Width := Page.SurfaceWidth;
  424. RichEditViewer.Height := Page.SurfaceHeight;
  425. RichEditViewer.Anchors := [akLeft, akTop, akRight, akBottom];
  426. RichEditViewer.BevelKind := bkFlat;
  427. RichEditViewer.BorderStyle := bsNone;
  428. RichEditViewer.Parent := Page.Surface;
  429. RichEditViewer.ScrollBars := ssVertical;
  430. RichEditViewer.UseRichEdit := True;
  431. RichEditViewer.RTFText := '{\rtf1\ansi\ansicpg1252\deff0\deflang1043{\fonttbl{\f0\fswiss\fcharset0 Arial;}}{\colortbl ;\red255\green0\blue0;\red0\green128\blue0;\red0\green0\blue128;}\viewkind4\uc1\pard\f0\fs20 T\cf1 Rich\cf2 Edit\cf3 Viewer\cf0\par}';
  432. RichEditViewer.ReadOnly := True;
  433. end;
  434. procedure AboutButtonOnClick(Sender: TObject);
  435. begin
  436. MsgBox('This demo shows some features of the various form objects and control classes.', mbInformation, mb_Ok);
  437. end;
  438. procedure CreateAboutButtonAndURLLabel(ParentForm: TSetupForm; CancelButton: TNewButton);
  439. var
  440. AboutButton: TNewButton;
  441. URLLabel: TNewLinkLabel;
  442. begin
  443. AboutButton := TNewButton.Create(ParentForm);
  444. AboutButton.Left := ParentForm.ClientWidth - CancelButton.Left - CancelButton.Width;
  445. AboutButton.Top := CancelButton.Top;
  446. AboutButton.Width := CancelButton.Width;
  447. AboutButton.Height := CancelButton.Height;
  448. AboutButton.Anchors := [akLeft, akBottom];
  449. AboutButton.Caption := '&About...';
  450. AboutButton.OnClick := @AboutButtonOnClick;
  451. AboutButton.Parent := ParentForm;
  452. URLLabel := TNewLinkLabel.Create(ParentForm);
  453. URLLabel.Left := AboutButton.Left + AboutButton.Width + ScaleX(20);
  454. URLLabel.Top := AboutButton.Top + (AboutButton.Height - URLLabel.Height) div 2;
  455. URLLabel.Anchors := [akLeft, akBottom];
  456. URLLabel.Caption := '<a href="https://jrsoftware.org">jrsoftware.org</a>';
  457. URLLabel.OnLinkClick := @LinkLabelOnLinkClick;
  458. URLLabel.UseVisualStyle := True;
  459. URLLabel.Parent := ParentForm;
  460. end;
  461. procedure InitializeWizard();
  462. begin
  463. { Custom wizard pages }
  464. CreateTheWizardPages;
  465. { Custom controls }
  466. CreateAboutButtonAndURLLabel(WizardForm, WizardForm.CancelButton);
  467. { Custom beveled label }
  468. WizardForm.BeveledLabel.Caption := ' Bevel ';
  469. end;
  470. procedure InitializeUninstallProgressForm();
  471. begin
  472. { Custom controls }
  473. CreateAboutButtonAndURLLabel(UninstallProgressForm, UninstallProgressForm.CancelButton);
  474. end;