2
0

CodeClasses.iss 22 KB

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