About.cpp 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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 AllowLicence, TRegistration * Registration)
  18. {
  19. TAboutDialog * AboutDialog = NULL;
  20. try
  21. {
  22. AboutDialog = new TAboutDialog(Application, Configuration, AllowLicence,
  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 AllowLicence, 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(PuttyLicenceLabel, "", 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_LICENCES, 1),
  69. (Registration->Licences >= 0 ? IntToStr(Registration->Licences) :
  70. LoadStrPart(ABOUT_REGISTRATION_LICENCES, 2)));
  71. if (!Registration->NeverExpires)
  72. {
  73. Text = FMTLOAD(ABOUT_REGISTRATION_EXPIRES,
  74. (Text, FormatDateTime("ddddd", Registration->Expiration)));
  75. }
  76. RegistrationLicencesLabel->Caption = Text;
  77. Text = FMTLOAD(ABOUT_REGISTRATION_PRODUCTID, (Registration->ProductId));
  78. if (Registration->EduLicense)
  79. {
  80. Text = FMTLOAD(ABOUT_REGISTRATION_EDULICENCE, (Text));
  81. }
  82. RegistrationProductIdLabel->Caption = Text;
  83. RegistrationProductIdLabel->Font->Style =
  84. RegistrationProductIdLabel->Font->Style << fsBold;
  85. }
  86. else
  87. {
  88. RegistrationLicencesLabel->Visible = false;
  89. RegistrationProductIdLabel->Visible = false;
  90. }
  91. }
  92. if (Translator.IsEmpty())
  93. {
  94. TranslatorLabel->Visible = false;
  95. TranslatorUrlLabel->Visible = false;
  96. ClientHeight = ClientHeight -
  97. (TranslatorLabel->Top - ProductSpecificMessageLabel->Top);
  98. }
  99. else
  100. {
  101. TranslatorLabel->Caption = LoadStr(TRANSLATOR_INFO);
  102. AnsiString TranslatorUrl = LoadStr(TRANSLATOR_URL);
  103. if (!TranslatorUrl.IsEmpty())
  104. {
  105. LinkLabel(TranslatorUrlLabel, TranslatorUrl);
  106. }
  107. else
  108. {
  109. TranslatorUrlLabel->Visible = false;
  110. }
  111. }
  112. #ifdef NO_FILEZILLA
  113. int FileZillaHeight = Label1->Top - FileZillaVersionLabel->Top;
  114. FileZillaVersionLabel->Visible = false;
  115. FileZillaCopyrightLabel->Visible = false;
  116. FileZillaHomepageLabel->Visible = false;
  117. for (int Index = 0; Index < ThirdPartyBox->ControlCount; Index++)
  118. {
  119. TControl * Control = ThirdPartyBox->Controls[Index];
  120. if (Control->Top > FileZillaHomepageLabel->Top)
  121. {
  122. Control->Top = Control->Top - FileZillaHeight;
  123. }
  124. }
  125. ThirdPartyBox->VertScrollBar->Range = ThirdPartyBox->VertScrollBar->Range - FileZillaHeight;
  126. #endif
  127. LicenceButton->Visible = AllowLicence;
  128. LoadData();
  129. }
  130. //---------------------------------------------------------------------------
  131. void __fastcall TAboutDialog::LoadData()
  132. {
  133. AnsiString Version = FConfiguration->VersionStr;
  134. if (!FConfiguration->ProductName.IsEmpty() &&
  135. (FConfiguration->Version != FConfiguration->ProductVersion))
  136. {
  137. Version = FMTLOAD(ABOUT_BASED_ON_PRODUCT,
  138. (Version, FConfiguration->ProductName, FConfiguration->ProductVersion));
  139. }
  140. VersionLabel->Caption = Version;
  141. }
  142. //---------------------------------------------------------------------------
  143. void __fastcall TAboutDialog::DisplayLicence(TObject * Sender)
  144. {
  145. DoLicenceDialog((TLicence)((TComponent*)Sender)->Tag);
  146. }
  147. //---------------------------------------------------------------------------
  148. void __fastcall TAboutDialog::LicenceButtonClick(TObject * /*Sender*/)
  149. {
  150. DoProductLicence();
  151. }
  152. //---------------------------------------------------------------------------
  153. void __fastcall TAboutDialog::HelpButtonClick(TObject * /*Sender*/)
  154. {
  155. FormHelp(this);
  156. }
  157. //---------------------------------------------------------------------------
  158. void __fastcall TAboutDialog::FirstScrollingControlEnter(TObject * /*Sender*/)
  159. {
  160. ThirdPartyBox->VertScrollBar->Position = 0;
  161. }
  162. //---------------------------------------------------------------------------
  163. void __fastcall TAboutDialog::LastScrollingControlEnter(TObject * /*Sender*/)
  164. {
  165. ThirdPartyBox->VertScrollBar->Position =
  166. ThirdPartyBox->VertScrollBar->Range - ThirdPartyBox->ClientHeight;
  167. }
  168. //---------------------------------------------------------------------------