IdAboutVCL.pas 12 KB

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