CodeClasses.iss 21 KB

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