About.cpp 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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(Toolbar2000HomepageLabel);
  44. LinkLabel(TBXHomepageLabel, "", LastScrollingControlEnter);
  45. ApplicationLabel->ParentFont = true;
  46. ApplicationLabel->Font->Style = ApplicationLabel->Font->Style << fsBold;
  47. ApplicationLabel->Caption = AppName;
  48. PuttyVersionLabel->Caption = FMTLOAD(PUTTY_BASED_ON, (LoadStr(PUTTY_VERSION)));
  49. PuttyCopyrightLabel->Caption = LoadStr(PUTTY_COPYRIGHT);
  50. WinSCPCopyrightLabel->Caption = LoadStr(WINSCP_COPYRIGHT);
  51. AnsiString Translator = LoadStr(TRANSLATOR_INFO);
  52. if (Registration == NULL)
  53. {
  54. RegistrationLabel->Visible = false;
  55. RegistrationBox->Visible = false;
  56. ClientHeight = ClientHeight -
  57. (ThirdPartyBox->Top - RegistrationBox->Top);
  58. }
  59. else
  60. {
  61. RegistrationSubjectLabel->Caption = Registration->Subject;
  62. if (Registration->Registered)
  63. {
  64. AnsiString Text;
  65. Text = FORMAT(LoadStrPart(ABOUT_REGISTRATION_LICENCES, 1),
  66. (Registration->Licences >= 0 ? IntToStr(Registration->Licences) :
  67. LoadStrPart(ABOUT_REGISTRATION_LICENCES, 2)));
  68. if (!Registration->NeverExpires)
  69. {
  70. Text = FMTLOAD(ABOUT_REGISTRATION_EXPIRES,
  71. (Text, FormatDateTime("ddddd", Registration->Expiration)));
  72. }
  73. RegistrationLicencesLabel->Caption = Text;
  74. Text = FMTLOAD(ABOUT_REGISTRATION_PRODUCTID, (Registration->ProductId));
  75. if (Registration->EduLicense)
  76. {
  77. Text = FMTLOAD(ABOUT_REGISTRATION_EDULICENCE, (Text));
  78. }
  79. RegistrationProductIdLabel->Caption = Text;
  80. RegistrationProductIdLabel->Font->Style =
  81. RegistrationProductIdLabel->Font->Style << fsBold;
  82. }
  83. else
  84. {
  85. RegistrationLicencesLabel->Visible = false;
  86. RegistrationProductIdLabel->Visible = false;
  87. }
  88. }
  89. if (Translator.IsEmpty())
  90. {
  91. TranslatorLabel->Visible = false;
  92. TranslatorUrlLabel->Visible = false;
  93. ClientHeight = ClientHeight -
  94. (TranslatorLabel->Top - ProductSpecificMessageLabel->Top);
  95. }
  96. else
  97. {
  98. TranslatorLabel->Caption = LoadStr(TRANSLATOR_INFO);
  99. LinkLabel(TranslatorUrlLabel, LoadStr(TRANSLATOR_URL));
  100. }
  101. LicenceButton->Visible = AllowLicence;
  102. LoadData();
  103. }
  104. //---------------------------------------------------------------------------
  105. void __fastcall TAboutDialog::LoadData()
  106. {
  107. AnsiString Version = FConfiguration->VersionStr;
  108. if (FConfiguration->Version != FConfiguration->ProductVersion)
  109. {
  110. Version = FMTLOAD(ABOUT_BASED_ON_PRODUCT,
  111. (Version, FConfiguration->ProductName, FConfiguration->ProductVersion));
  112. }
  113. VersionLabel->Caption = Version;
  114. }
  115. //---------------------------------------------------------------------------
  116. void __fastcall TAboutDialog::DisplayLicence(TObject * Sender)
  117. {
  118. DoLicenceDialog((TLicence)((TComponent*)Sender)->Tag);
  119. }
  120. //---------------------------------------------------------------------------
  121. void __fastcall TAboutDialog::LicenceButtonClick(TObject * /*Sender*/)
  122. {
  123. DoProductLicence();
  124. }
  125. //---------------------------------------------------------------------------
  126. void __fastcall TAboutDialog::HelpButtonClick(TObject * /*Sender*/)
  127. {
  128. FormHelp(this);
  129. }
  130. //---------------------------------------------------------------------------
  131. void __fastcall TAboutDialog::FirstScrollingControlEnter(TObject * /*Sender*/)
  132. {
  133. ThirdPartyBox->VertScrollBar->Position = 0;
  134. }
  135. //---------------------------------------------------------------------------
  136. void __fastcall TAboutDialog::LastScrollingControlEnter(TObject * /*Sender*/)
  137. {
  138. ThirdPartyBox->VertScrollBar->Position =
  139. ThirdPartyBox->VertScrollBar->Range - ThirdPartyBox->ClientHeight;
  140. }
  141. //---------------------------------------------------------------------------