About.cpp 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. //---------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include <SysUtils.hpp>
  5. //---------------------------------------------------------------------
  6. #include <VCLCommon.h>
  7. #include <Common.h>
  8. #include <Tools.h>
  9. #include "WinInterface.h"
  10. #include "About.h"
  11. #include "TextsCore.h"
  12. #include "TextsWin.h"
  13. //---------------------------------------------------------------------
  14. #pragma resource "*.dfm"
  15. //---------------------------------------------------------------------------
  16. void __fastcall DoAboutDialog(TConfiguration * Configuration,
  17. bool AllowLicense, TRegistration * Registration)
  18. {
  19. TAboutDialog * AboutDialog = NULL;
  20. try
  21. {
  22. AboutDialog = new TAboutDialog(Application, Configuration, AllowLicense,
  23. Registration);
  24. AboutDialog->ShowModal();
  25. }
  26. __finally
  27. {
  28. delete AboutDialog;
  29. }
  30. }
  31. //---------------------------------------------------------------------------
  32. __fastcall TAboutDialog::TAboutDialog(TComponent * AOwner,
  33. TConfiguration * Configuration, bool AllowLicense, TRegistration * Registration)
  34. : TForm(AOwner)
  35. {
  36. FConfiguration = Configuration;
  37. ThirdPartyBox->VertScrollBar->Position = 0;
  38. UseSystemSettings(this);
  39. LinkLabel(HomepageLabel, LoadStr(HOMEPAGE_URL));
  40. LinkLabel(ForumUrlLabel, LoadStr(FORUM_URL));
  41. LinkLabel(PuttyLicenseLabel, "", FirstScrollingControlEnter);
  42. LinkLabel(PuttyHomepageLabel, LoadStr(PUTTY_URL));
  43. LinkLabel(FileZillaHomepageLabel, LoadStr(FILEZILLA_URL));
  44. LinkLabel(Toolbar2000HomepageLabel);
  45. LinkLabel(TBXHomepageLabel, "", LastScrollingControlEnter);
  46. ApplicationLabel->ParentFont = true;
  47. ApplicationLabel->Font->Style = ApplicationLabel->Font->Style << fsBold;
  48. ApplicationLabel->Caption = AppName;
  49. PuttyVersionLabel->Caption = FMTLOAD(PUTTY_BASED_ON, (LoadStr(PUTTY_VERSION)));
  50. PuttyCopyrightLabel->Caption = LoadStr(PUTTY_COPYRIGHT);
  51. FileZillaVersionLabel->Caption = FMTLOAD(FILEZILLA_BASED_ON, (LoadStr(FILEZILLA_VERSION)));
  52. FileZillaCopyrightLabel->Caption = LoadStr(FILEZILLA_COPYRIGHT);
  53. WinSCPCopyrightLabel->Caption = LoadStr(WINSCP_COPYRIGHT);
  54. AnsiString Translator = LoadStr(TRANSLATOR_INFO);
  55. if (Registration == NULL)
  56. {
  57. RegistrationLabel->Visible = false;
  58. RegistrationBox->Visible = false;
  59. ClientHeight = ClientHeight -
  60. (ThirdPartyBox->Top - RegistrationBox->Top);
  61. }
  62. else
  63. {
  64. RegistrationSubjectLabel->Caption = Registration->Subject;
  65. if (Registration->Registered)
  66. {
  67. AnsiString Text;
  68. Text = FORMAT(LoadStrPart(ABOUT_REGISTRATION_LICENSES, 1),
  69. (Registration->Licenses >= 0 ? IntToStr(Registration->Licenses) :
  70. LoadStrPart(ABOUT_REGISTRATION_LICENSES, 2)));
  71. if (!Registration->NeverExpires)
  72. {
  73. Text = FMTLOAD(ABOUT_REGISTRATION_EXPIRES,
  74. (Text, FormatDateTime("ddddd", Registration->Expiration)));
  75. }
  76. RegistrationLicensesLabel->Caption = Text;
  77. Text = FMTLOAD(ABOUT_REGISTRATION_PRODUCTID, (Registration->ProductId));
  78. if (Registration->EduLicense)
  79. {
  80. Text = FMTLOAD(ABOUT_REGISTRATION_EDULICENSE, (Text));
  81. }
  82. RegistrationProductIdLabel->Caption = Text;
  83. RegistrationProductIdLabel->Font->Style =
  84. RegistrationProductIdLabel->Font->Style << fsBold;
  85. }
  86. else
  87. {
  88. RegistrationLicensesLabel->Visible = false;
  89. FRegistrationLink = Registration->RegistrationLink;
  90. RegistrationProductIdLabel->Caption = LoadStr(ABOUT_REGISTRATION_LINK);
  91. LinkLabel(RegistrationProductIdLabel, "");
  92. }
  93. }
  94. if (Translator.IsEmpty())
  95. {
  96. TranslatorLabel->Visible = false;
  97. TranslatorUrlLabel->Visible = false;
  98. ClientHeight = ClientHeight -
  99. (TranslatorLabel->Top - ProductSpecificMessageLabel->Top);
  100. }
  101. else
  102. {
  103. TranslatorLabel->Caption = LoadStr(TRANSLATOR_INFO);
  104. AnsiString TranslatorUrl = LoadStr(TRANSLATOR_URL);
  105. if (!TranslatorUrl.IsEmpty())
  106. {
  107. LinkLabel(TranslatorUrlLabel, TranslatorUrl);
  108. }
  109. else
  110. {
  111. TranslatorUrlLabel->Visible = false;
  112. }
  113. }
  114. #ifdef NO_FILEZILLA
  115. int FileZillaHeight = Label1->Top - FileZillaVersionLabel->Top;
  116. FileZillaVersionLabel->Visible = false;
  117. FileZillaCopyrightLabel->Visible = false;
  118. FileZillaHomepageLabel->Visible = false;
  119. for (int Index = 0; Index < ThirdPartyBox->ControlCount; Index++)
  120. {
  121. TControl * Control = ThirdPartyBox->Controls[Index];
  122. if (Control->Top > FileZillaHomepageLabel->Top)
  123. {
  124. Control->Top = Control->Top - FileZillaHeight;
  125. }
  126. }
  127. ThirdPartyBox->VertScrollBar->Range = ThirdPartyBox->VertScrollBar->Range - FileZillaHeight;
  128. #endif
  129. LicenseButton->Visible = AllowLicense;
  130. LoadData();
  131. }
  132. //---------------------------------------------------------------------------
  133. void __fastcall TAboutDialog::LoadData()
  134. {
  135. AnsiString Version = FConfiguration->VersionStr;
  136. if (!FConfiguration->ProductName.IsEmpty() &&
  137. (FConfiguration->Version != FConfiguration->ProductVersion))
  138. {
  139. Version = FMTLOAD(ABOUT_BASED_ON_PRODUCT,
  140. (Version, FConfiguration->ProductName, FConfiguration->ProductVersion));
  141. }
  142. VersionLabel->Caption = Version;
  143. }
  144. //---------------------------------------------------------------------------
  145. void __fastcall TAboutDialog::DisplayLicense(TObject * Sender)
  146. {
  147. DoLicenseDialog((TLicense)((TComponent*)Sender)->Tag);
  148. }
  149. //---------------------------------------------------------------------------
  150. void __fastcall TAboutDialog::LicenseButtonClick(TObject * /*Sender*/)
  151. {
  152. DoProductLicense();
  153. }
  154. //---------------------------------------------------------------------------
  155. void __fastcall TAboutDialog::HelpButtonClick(TObject * /*Sender*/)
  156. {
  157. FormHelp(this);
  158. }
  159. //---------------------------------------------------------------------------
  160. void __fastcall TAboutDialog::FirstScrollingControlEnter(TObject * /*Sender*/)
  161. {
  162. ThirdPartyBox->VertScrollBar->Position = 0;
  163. }
  164. //---------------------------------------------------------------------------
  165. void __fastcall TAboutDialog::LastScrollingControlEnter(TObject * /*Sender*/)
  166. {
  167. ThirdPartyBox->VertScrollBar->Position =
  168. ThirdPartyBox->VertScrollBar->Range - ThirdPartyBox->ClientHeight;
  169. }
  170. //---------------------------------------------------------------------------
  171. void __fastcall TAboutDialog::RegistrationProductIdLabelClick(
  172. TObject * /*Sender*/)
  173. {
  174. if (!FRegistrationLink.IsEmpty())
  175. {
  176. OpenBrowser(FRegistrationLink);
  177. }
  178. }
  179. //---------------------------------------------------------------------------