IdAboutVCL.pas 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. unit IdAboutVCL;
  2. interface
  3. {$I IdCompilerDefines.inc}
  4. uses
  5. {$IFDEF WIDGET_KYLIX}
  6. QStdCtrls, QForms, QExtCtrls, QControls, QComCtrls, QGraphics, Qt,
  7. {$ENDIF}
  8. {$IFDEF WIDGET_VCL_LIKE}
  9. StdCtrls, Buttons, ExtCtrls, Graphics, Controls, ComCtrls, Forms,
  10. {$ENDIF}
  11. {$IFDEF HAS_UNIT_Types}
  12. Types,
  13. {$ENDIF}
  14. {$IFDEF WIDGET_LCL}
  15. LResources,
  16. {$ENDIF}
  17. Classes, SysUtils;
  18. type
  19. TfrmAbout = class(TForm)
  20. protected
  21. FimLogo : TImage;
  22. FlblCopyRight : TLabel;
  23. FlblName : TLabel;
  24. FlblName2 : TLabel;
  25. FlblVersion : TLabel;
  26. FlblBuiltFor : TLabel;
  27. FlblLicense : TLabel;
  28. FlblPleaseVisitUs : TLabel;
  29. FlblURL : TLabel;
  30. //for LCL, we use a TBitBtn to be consistant with some GUI interfaces
  31. //and the Lazarus IDE.
  32. {$IFDEF USE_TBitBtn}
  33. FbbtnOk : TBitBtn;
  34. {$ELSE}
  35. FbbtnOk : TButton;
  36. {$ENDIF}
  37. procedure lblURLClick(Sender: TObject);
  38. function GetProductName: String;
  39. procedure SetProductName(const AValue: String);
  40. function GetProductName2: String;
  41. procedure SetProductName2(const AValue: String);
  42. function GetVersion: String;
  43. procedure SetVersion(const AValue: String);
  44. public
  45. //we have a method for providing a product name and version in case
  46. //we ever want to make another product.
  47. class procedure ShowDlg;
  48. class procedure ShowAboutBox(const AProductName, AProductName2, AProductVersion: String);
  49. constructor Create(AOwner : TComponent); overload; override;
  50. constructor Create; reintroduce; overload;
  51. property ProductName : String read GetProductName write SetProductName;
  52. property ProductName2 : String read GetProductName2 write SetProductName2;
  53. property Version : String read GetVersion write SetVersion;
  54. end;
  55. implementation
  56. {$IFNDEF WIDGET_LCL}
  57. {$IFDEF WIN32_OR_WIN64}
  58. {$R IdAboutVCL.RES}
  59. {$ENDIF}
  60. {$IFDEF KYLIX}
  61. {$R IdAboutVCL.RES}
  62. {$ENDIF}
  63. {$ENDIF}
  64. uses
  65. {$IFDEF WIN32_OR_WIN64}ShellApi, {$ENDIF}
  66. {$IFNDEF WIDGET_LCL}
  67. //done this way because we reference HInstance in Delphi for loading
  68. //resources. Lazarus does something different.
  69. {$IFDEF WIN32_OR_WIN64}
  70. Windows,
  71. {$ENDIF}
  72. {$ENDIF}
  73. IdDsnCoreResourceStrings,
  74. IdGlobal;
  75. {$IFNDEF WIDGET_LCL}
  76. function RGBToColor(R, G, B: Byte): TColor;
  77. begin
  78. Result := RGB(R, G, B);
  79. end;
  80. {$ENDIF}
  81. { TfrmAbout }
  82. constructor TfrmAbout.Create(AOwner: TComponent);
  83. begin
  84. inherited CreateNew(AOwner,0);
  85. FimLogo := TImage.Create(Self);
  86. FlblCopyRight := TLabel.Create(Self);
  87. FlblName := TLabel.Create(Self);
  88. FlblName2 := TLabel.Create(Self);
  89. FlblVersion := TLabel.Create(Self);
  90. FlblBuiltFor := TLabel.Create(Self);
  91. FlblLicense := TLabel.Create(Self);
  92. FlblPleaseVisitUs := TLabel.Create(Self);
  93. FlblURL := TLabel.Create(Self);
  94. {$IFDEF USE_TBitBtn}
  95. FbbtnOk := TBitBtn.Create(Self);
  96. {$ELSE}
  97. FbbtnOk := TButton.Create(Self);
  98. {$ENDIF}
  99. Name := 'formAbout';
  100. Left := 0;
  101. Top := 0;
  102. Anchors := [];//[akLeft, akTop, akRight,akBottom];
  103. BorderIcons := [biSystemMenu];
  104. BorderStyle := bsDialog;
  105. Caption := RSAAboutFormCaption;
  106. ClientHeight := 336;
  107. ClientWidth := 554;
  108. Color := 2520226; // RGBToColor(38, 116, 162)
  109. Font.Color := 16776138; // RGBToColor(202, 251, 255)
  110. Font.Height := -12;
  111. Font.Size := 9;
  112. Font.Name := 'Arial';
  113. Font.Style := [];
  114. Position := poScreenCenter;
  115. {$IFDEF WIDGET_VCL}
  116. Scaled := True;
  117. {$ENDIF}
  118. Constraints.MinHeight := Height;
  119. Constraints.MinWidth := Width;
  120. // PixelsPerInch := 96;
  121. FimLogo.Name := 'imLogo';
  122. FimLogo.Parent := Self;
  123. FimLogo.Left := 0;
  124. FimLogo.Top := 0;
  125. FimLogo.Width := 388;
  126. FimLogo.Height := 240;
  127. {$IFDEF WIDGET_LCL}
  128. FimLogo.Picture.Pixmap.LoadFromLazarusResource('IndyAboutBkgnd'); //this is XPM format, so Pixmap is used
  129. FimLogo.Align := alClient;
  130. FimLogo.Stretch := True;
  131. {$ELSE} // Because Lazarus is also WIDGET_VCL_LIKE_OR_KYLIX
  132. {$IFDEF WIDGET_VCL_LIKE_OR_KYLIX}
  133. FimLogo.Picture.Bitmap.LoadFromResourceName(HInstance, 'INDY_ABOUT_BACKGROUND'); {Do not Localize}
  134. FimLogo.Align := alClient;
  135. FimLogo.Stretch := True;
  136. {$ENDIF}
  137. {$ENDIF}
  138. FlblName.Name := 'lblName';
  139. FlblName.Parent := Self;
  140. FlblName.Left := 51;
  141. FlblName.Top := 28;
  142. FlblName.Width := 200;
  143. FlblName.Height := 101;
  144. FlblName.Anchors := [akLeft, akTop];
  145. {$IFDEF WIDGET_VCL}
  146. FlblName.Font.Charset := DEFAULT_CHARSET;
  147. FlblName.Transparent := True;
  148. {$ENDIF}
  149. FlblName.Font.Color := clWhite;
  150. FlblName.Font.Height := -72;
  151. FlblName.Font.Name := 'Arial Black';
  152. FlblName.Font.Style := [];
  153. FlblName.ParentFont := False;
  154. FlblName.WordWrap := False;
  155. FlblName.Caption := RSAAboutBoxTitle1;
  156. FlblName2.Name := 'lblName2';
  157. FlblName2.Parent := Self;
  158. FlblName2.Left := 54;
  159. FlblName2.Top := 110;
  160. FlblName2.Width := 192;
  161. FlblName2.Height := 35;
  162. FlblName2.Anchors := [akLeft, akTop];
  163. {$IFDEF WIDGET_VCL}
  164. FlblName2.Font.Charset := DEFAULT_CHARSET;
  165. FlblName2.Transparent := True;
  166. {$ENDIF}
  167. FlblName2.Font.Color := clWhite;
  168. FlblName2.Font.Height := -31;
  169. FlblName2.Font.Name := 'Arial';
  170. FlblName2.Font.Style := [];
  171. FlblName2.ParentFont := False;
  172. FlblName2.WordWrap := False;
  173. FlblName2.Caption := RSAAboutBoxTitle2;
  174. FlblVersion.Name := 'lblVersion';
  175. FlblVersion.Parent := Self;
  176. FlblVersion.Left := 300;
  177. FlblVersion.Top := 170;
  178. FlblVersion.Width := 200;
  179. FlblVersion.Height := 17;
  180. FlblVersion.Alignment := taRightJustify;
  181. FlblVersion.AutoSize := False;
  182. {$IFDEF WIDGET_VCL}
  183. FlblVersion.Font.Charset := DEFAULT_CHARSET;
  184. FlblVersion.Transparent := True;
  185. {$ENDIF}
  186. FlblVersion.Font.Color := 16776138; // RGBToColor(202, 251, 255)
  187. FlblVersion.Font.Height := -15;
  188. FlblVersion.Font.Name := 'Arial';
  189. FlblVersion.Font.Style := [fsBold];
  190. FlblVersion.ParentFont := False;
  191. FlblVersion.Anchors := [akTop, akRight];
  192. FlblBuiltFor.Name := 'lblBuiltFor';
  193. FlblBuiltFor.Parent := Self;
  194. FlblBuiltFor.Left := 300;
  195. FlblBuiltFor.Top := 188;
  196. FlblBuiltFor.Width := 200;
  197. FlblBuiltFor.Height := 17;
  198. FlblBuiltFor.Alignment := taRightJustify;
  199. FlblBuiltFor.AutoSize := False;
  200. {$IFDEF WIDGET_VCL}
  201. FlblBuiltFor.Font.Charset := DEFAULT_CHARSET;
  202. FlblBuiltFor.Transparent := True;
  203. {$ENDIF}
  204. FlblBuiltFor.Font.Color := 16776138; // RGBToColor(202, 251, 255)
  205. FlblBuiltFor.Font.Height := -14;
  206. FlblBuiltFor.Font.Name := 'Arial';
  207. FlblBuiltFor.Font.Style := [];
  208. FlblBuiltFor.ParentFont := False;
  209. FlblBuiltFor.Anchors := [akTop, akRight];
  210. // RLebeau: not using resouce strings for the product names because:
  211. // 1. the names are pretty specific and not likely to change with localization;
  212. // 2. we are trying to avoid using IFDEFs in resource units, per Embarcadero's request;
  213. // 3. I don't want to create more product-specific resource units unless we really need them;
  214. {$IFDEF WIDGET_KYLIX}
  215. FlblBuiltFor.Caption := IndyFormat(RSAAboutBoxBuiltFor, ['Kylix']);
  216. {$ELSE}
  217. {$IFDEF WIDGET_VCL}
  218. FlblBuiltFor.Caption := IndyFormat(RSAAboutBoxBuiltFor, ['VCL']);
  219. {$ELSE}
  220. {$IFDEF WIDGET_LCL}
  221. FlblBuiltFor.Caption := IndyFormat(RSAAboutBoxBuiltFor, ['Lazarus']);
  222. {$ELSE}
  223. FlblBuiltFor.Caption := IndyFormat(RSAAboutBoxBuiltFor, ['Unknown']);
  224. {$ENDIF}
  225. {$ENDIF}
  226. {$ENDIF}
  227. FlblLicense.Name := 'lblLicense';
  228. FlblLicense.Parent := Self;
  229. FlblLicense.Left := 300;
  230. FlblLicense.Top := 227;
  231. FlblLicense.Width := 200;
  232. FlblLicense.Height := 45;
  233. FlblLicense.Alignment := taRightJustify;
  234. FlblLicense.AutoSize := False;
  235. {$IFDEF WIDGET_VCL}
  236. FlblLicense.Font.Charset := DEFAULT_CHARSET;
  237. FlblLicense.Transparent := True;
  238. {$ENDIF}
  239. FlblLicense.Font.Color := 16776138; // RGBToColor(202, 251, 255)
  240. FlblLicense.Font.Height := -12;
  241. FlblLicense.Font.Name := 'Arial';
  242. FlblLicense.Font.Style := [];
  243. FlblLicense.ParentFont := False;
  244. FlblLicense.WordWrap := True;
  245. FlblLicense.Anchors := [akTop, akRight];
  246. FlblLicense.Caption := RSAAboutBoxLicences;
  247. FlblCopyRight.Name := 'lblCopyRight';
  248. FlblCopyRight.Parent := Self;
  249. FlblCopyRight.Left := 58;
  250. FlblCopyRight.Top := 171;
  251. FlblCopyRight.Width := 138;
  252. FlblCopyRight.Height := 15;
  253. FlblCopyRight.Caption := RSAAboutBoxCopyright;
  254. {$IFDEF WIDGET_VCL}
  255. FlblCopyRight.Font.Charset := DEFAULT_CHARSET;
  256. FlblCopyRight.Transparent := True;
  257. {$ENDIF}
  258. FlblCopyRight.Font.Color := 16776138; // RGBToColor(202, 251, 255)
  259. FlblCopyRight.Font.Height := -12;
  260. FlblCopyRight.Font.Name := 'Arial';
  261. FlblCopyRight.Font.Style := [];
  262. FlblCopyRight.ParentFont := False;
  263. FlblCopyRight.WordWrap := True;
  264. FlblPleaseVisitUs.Name := 'lblPleaseVisitUs';
  265. FlblPleaseVisitUs.Parent := Self;
  266. FlblPleaseVisitUs.Left := 58;
  267. FlblPleaseVisitUs.Top := 278;
  268. FlblPleaseVisitUs.Width := 276;
  269. FlblPleaseVisitUs.Height := 15;
  270. {$IFDEF WIDGET_VCL}
  271. FlblPleaseVisitUs.Font.Charset := DEFAULT_CHARSET;
  272. FlblPleaseVisitUs.Transparent := True;
  273. {$ENDIF}
  274. FlblPleaseVisitUs.Font.Color := 16776138; // RGBToColor(202, 251, 255)
  275. FlblPleaseVisitUs.Font.Height := -12;
  276. FlblPleaseVisitUs.Font.Name := 'Arial';
  277. FlblPleaseVisitUs.ParentFont := False;
  278. FlblPleaseVisitUs.Caption := RSAAboutBoxPleaseVisit;
  279. FlblPleaseVisitUs.Anchors := [akLeft, akTop];
  280. FlblURL.Name := 'lblURL';
  281. FlblURL.Left := 58;
  282. FlblURL.Top := 292;
  283. FlblURL.Width := 141;
  284. FlblURL.Height := 15;
  285. FlblURL.Cursor := crHandPoint;
  286. {$IFDEF WIDGET_VCL}
  287. FlblURL.Font.Charset := DEFAULT_CHARSET;
  288. FlblURL.Transparent := True;
  289. {$ENDIF}
  290. FlblURL.Font.Color := 16776138; // RGBToColor(202, 251, 255)
  291. FlblURL.Font.Height := -12;
  292. FlblURL.Font.Name := 'Arial';
  293. FlblURL.ParentFont := False;
  294. FlblURL.OnClick := lblURLClick;
  295. FlblURL.Caption := RSAAboutBoxIndyWebsite;
  296. FlblURL.Anchors := [akLeft, akTop];
  297. FlblURL.Parent := Self;
  298. FbbtnOk.Name := 'bbtnOk';
  299. FbbtnOk.Left := 475;
  300. {$IFDEF USE_TBitBtn}
  301. FbbtnOk.Top := 297;
  302. {$ELSE}
  303. FbbtnOk.Top := 302;
  304. FbbtnOk.Height := 25;
  305. {$ENDIF}
  306. FbbtnOk.Width := 75;
  307. FbbtnOk.Anchors := [akRight, akBottom];
  308. {$IFDEF USE_TBitBtn}
  309. FbbtnOk.Font.Color := clBlack;
  310. FbbtnOk.ParentFont := False;
  311. FbbtnOk.Kind := bkOk;
  312. {$ELSE}
  313. FbbtnOk.Caption := RSOk;
  314. {$ENDIF}
  315. FbbtnOk.Cancel := True;
  316. FbbtnOk.Default := True;
  317. FbbtnOk.ModalResult := 1;
  318. FbbtnOk.TabOrder := 0;
  319. FbbtnOk.Anchors := [akLeft, akTop, akRight];
  320. FbbtnOk.Parent := Self;
  321. end;
  322. function TfrmAbout.GetVersion: String;
  323. begin
  324. Result := FlblVersion.Caption;
  325. end;
  326. function TfrmAbout.GetProductName: String;
  327. begin
  328. Result := FlblName.Caption;
  329. end;
  330. function TfrmAbout.GetProductName2: String;
  331. begin
  332. Result := FlblName2.Caption;
  333. end;
  334. procedure TfrmAbout.lblURLClick(Sender: TObject);
  335. begin
  336. {$IFDEF WIN32_OR_WIN64}
  337. ShellAPI.ShellExecute(Handle, nil, PChar(FlblURL.Caption), nil, nil, 0); {Do not Localize}
  338. FlblURL.Font.Color := clPurple;
  339. {$ENDIF}
  340. end;
  341. procedure TfrmAbout.SetVersion(const AValue: String);
  342. begin
  343. FlblVersion.Caption := AValue;
  344. end;
  345. procedure TfrmAbout.SetProductName(const AValue: String);
  346. begin
  347. FlblName.Caption := AValue;
  348. end;
  349. procedure TfrmAbout.SetProductName2(const AValue: String);
  350. begin
  351. FlblName2.Caption := AValue;
  352. end;
  353. class procedure TfrmAbout.ShowAboutBox(const AProductName, AProductName2, AProductVersion: String);
  354. var
  355. LFrm: TfrmAbout;
  356. begin
  357. LFrm := TfrmAbout.Create;
  358. {$IFNDEF USE_OBJECT_ARC}
  359. try
  360. {$ENDIF}
  361. LFrm.Version := IndyFormat(RSAAboutBoxVersion, [AProductVersion]);
  362. LFrm.ProductName := AProductName;
  363. LFrm.ProductName2 := AProductName2;
  364. LFrm.ShowModal;
  365. {$IFNDEF USE_OBJECT_ARC}
  366. finally
  367. LFrm.Free;
  368. end;
  369. {$ENDIF}
  370. end;
  371. class procedure TfrmAbout.ShowDlg;
  372. begin
  373. ShowAboutBox(RSAAboutBoxTitle1, RSAAboutBoxTitle2, gsIdVersion);
  374. end;
  375. constructor TfrmAbout.Create;
  376. begin
  377. Create(nil);
  378. end;
  379. {$IFDEF WIDGET_LCL}
  380. initialization
  381. {$i IdAboutVCL.lrs}
  382. {$ENDIF}
  383. end.