About.cpp 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. LinkLabel(TranslatorUrlLabel, LoadStr(TRANSLATOR_URL));
  103. }
  104. #ifdef NO_FILEZILLA
  105. int FileZillaHeight = Label1->Top - FileZillaVersionLabel->Top;
  106. FileZillaVersionLabel->Visible = false;
  107. FileZillaCopyrightLabel->Visible = false;
  108. FileZillaHomepageLabel->Visible = false;
  109. for (int Index = 0; Index < ThirdPartyBox->ControlCount; Index++)
  110. {
  111. TControl * Control = ThirdPartyBox->Controls[Index];
  112. if (Control->Top > FileZillaHomepageLabel->Top)
  113. {
  114. Control->Top = Control->Top - FileZillaHeight;
  115. }
  116. }
  117. ThirdPartyBox->VertScrollBar->Range = ThirdPartyBox->VertScrollBar->Range - FileZillaHeight;
  118. #endif
  119. LicenceButton->Visible = AllowLicence;
  120. LoadData();
  121. }
  122. //---------------------------------------------------------------------------
  123. void __fastcall TAboutDialog::LoadData()
  124. {
  125. AnsiString Version = FConfiguration->VersionStr;
  126. if (FConfiguration->Version != FConfiguration->ProductVersion)
  127. {
  128. Version = FMTLOAD(ABOUT_BASED_ON_PRODUCT,
  129. (Version, FConfiguration->ProductName, FConfiguration->ProductVersion));
  130. }
  131. VersionLabel->Caption = Version;
  132. }
  133. //---------------------------------------------------------------------------
  134. void __fastcall TAboutDialog::DisplayLicence(TObject * Sender)
  135. {
  136. DoLicenceDialog((TLicence)((TComponent*)Sender)->Tag);
  137. }
  138. //---------------------------------------------------------------------------
  139. void __fastcall TAboutDialog::LicenceButtonClick(TObject * /*Sender*/)
  140. {
  141. DoProductLicence();
  142. }
  143. //---------------------------------------------------------------------------
  144. void __fastcall TAboutDialog::HelpButtonClick(TObject * /*Sender*/)
  145. {
  146. FormHelp(this);
  147. }
  148. //---------------------------------------------------------------------------
  149. void __fastcall TAboutDialog::FirstScrollingControlEnter(TObject * /*Sender*/)
  150. {
  151. ThirdPartyBox->VertScrollBar->Position = 0;
  152. }
  153. //---------------------------------------------------------------------------
  154. void __fastcall TAboutDialog::LastScrollingControlEnter(TObject * /*Sender*/)
  155. {
  156. ThirdPartyBox->VertScrollBar->Position =
  157. ThirdPartyBox->VertScrollBar->Range - ThirdPartyBox->ClientHeight;
  158. }
  159. //---------------------------------------------------------------------------