About.cpp 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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. #ifndef NO_RESOURCES
  15. #pragma resource "*.dfm"
  16. #endif
  17. //---------------------------------------------------------------------------
  18. void __fastcall DoAboutDialog(TConfiguration * Configuration,
  19. bool AllowLicense, TRegistration * Registration)
  20. {
  21. TAboutDialog * AboutDialog = NULL;
  22. try
  23. {
  24. AboutDialog = new TAboutDialog(Application, Configuration, AllowLicense,
  25. Registration);
  26. AboutDialog->ShowModal();
  27. }
  28. __finally
  29. {
  30. delete AboutDialog;
  31. }
  32. }
  33. //---------------------------------------------------------------------------
  34. __fastcall TAboutDialog::TAboutDialog(TComponent * AOwner,
  35. TConfiguration * Configuration, bool AllowLicense, TRegistration * Registration)
  36. : TForm(AOwner)
  37. {
  38. FConfiguration = Configuration;
  39. ThirdPartyBox->VertScrollBar->Position = 0;
  40. UseSystemSettings(this);
  41. LinkLabel(HomepageLabel, LoadStr(HOMEPAGE_URL));
  42. LinkLabel(ForumUrlLabel, LoadStr(FORUM_URL));
  43. LinkLabel(PuttyLicenseLabel, L"", FirstScrollingControlEnter);
  44. LinkLabel(PuttyHomepageLabel, LoadStr(PUTTY_URL));
  45. LinkLabel(FileZillaHomepageLabel, LoadStr(FILEZILLA_URL));
  46. LinkLabel(OpenSSLHomepageLabel, LoadStr(OPENSSL_URL));
  47. LinkLabel(Toolbar2000HomepageLabel);
  48. LinkLabel(TBXHomepageLabel, L"", LastScrollingControlEnter);
  49. ApplicationLabel->ParentFont = true;
  50. ApplicationLabel->Font->Style = ApplicationLabel->Font->Style << fsBold;
  51. ApplicationLabel->Caption = AppName;
  52. PuttyVersionLabel->Caption = FMTLOAD(PUTTY_BASED_ON, (LoadStr(PUTTY_VERSION)));
  53. PuttyCopyrightLabel->Caption = LoadStr(PUTTY_COPYRIGHT);
  54. FileZillaVersionLabel->Caption = LoadStr(FILEZILLA_BASED_ON2);
  55. FileZillaCopyrightLabel->Caption = LoadStr(FILEZILLA_COPYRIGHT2);
  56. OpenSSLVersionLabel->Caption = FMTLOAD(OPENSSL_BASED_ON, (LoadStr(OPENSSL_VERSION)));
  57. OpenSSLCopyrightLabel->Caption = LoadStr(OPENSSL_COPYRIGHT);
  58. WinSCPCopyrightLabel->Caption = LoadStr(WINSCP_COPYRIGHT);
  59. UnicodeString Translator = LoadStr(TRANSLATOR_INFO);
  60. if (Registration == NULL)
  61. {
  62. RegistrationLabel->Visible = false;
  63. RegistrationBox->Visible = false;
  64. ClientHeight = ClientHeight -
  65. (ThirdPartyBox->Top - RegistrationBox->Top);
  66. }
  67. else
  68. {
  69. RegistrationSubjectLabel->Caption = Registration->Subject;
  70. if (Registration->Registered)
  71. {
  72. UnicodeString Text;
  73. Text = FORMAT(LoadStrPart(ABOUT_REGISTRATION_LICENSES, 1),
  74. (Registration->Licenses >= 0 ? IntToStr(Registration->Licenses) :
  75. UnicodeString(LoadStrPart(ABOUT_REGISTRATION_LICENSES, 2))));
  76. if (!Registration->NeverExpires)
  77. {
  78. Text = FMTLOAD(ABOUT_REGISTRATION_EXPIRES,
  79. (Text, FormatDateTime(L"ddddd", Registration->Expiration)));
  80. }
  81. RegistrationLicensesLabel->Caption = Text;
  82. Text = FMTLOAD(ABOUT_REGISTRATION_PRODUCTID, (Registration->ProductId));
  83. if (Registration->EduLicense)
  84. {
  85. Text = FMTLOAD(ABOUT_REGISTRATION_EDULICENSE, (Text));
  86. }
  87. RegistrationProductIdLabel->Caption = Text;
  88. RegistrationProductIdLabel->Font->Style =
  89. RegistrationProductIdLabel->Font->Style << fsBold;
  90. }
  91. else
  92. {
  93. RegistrationLicensesLabel->Visible = false;
  94. FOnRegistrationLink = Registration->OnRegistrationLink;
  95. RegistrationProductIdLabel->Caption = LoadStr(ABOUT_REGISTRATION_LINK);
  96. LinkLabel(RegistrationProductIdLabel, L"");
  97. }
  98. }
  99. if (Translator.IsEmpty())
  100. {
  101. TranslatorLabel->Visible = false;
  102. TranslatorUrlLabel->Visible = false;
  103. ClientHeight = ClientHeight -
  104. (TranslatorLabel->Top - ProductSpecificMessageLabel->Top);
  105. }
  106. else
  107. {
  108. TranslatorLabel->Caption = LoadStr(TRANSLATOR_INFO);
  109. UnicodeString TranslatorUrl = LoadStr(TRANSLATOR_URL);
  110. if (!TranslatorUrl.IsEmpty())
  111. {
  112. LinkLabel(TranslatorUrlLabel, TranslatorUrl);
  113. }
  114. else
  115. {
  116. TranslatorUrlLabel->Visible = false;
  117. }
  118. }
  119. #ifdef NO_FILEZILLA
  120. int FileZillaHeight = Label1->Top - FileZillaVersionLabel->Top;
  121. FileZillaVersionLabel->Visible = false;
  122. FileZillaCopyrightLabel->Visible = false;
  123. FileZillaHomepageLabel->Visible = false;
  124. OpenSSLVersionLabel->Visible = false;
  125. OpenSSLCopyrightLabel->Visible = false;
  126. OpenSSLHomepageLabel->Visible = false;
  127. for (int Index = 0; Index < ThirdPartyBox->ControlCount; Index++)
  128. {
  129. TControl * Control = ThirdPartyBox->Controls[Index];
  130. if (Control->Top > FileZillaHomepageLabel->Top)
  131. {
  132. Control->Top = Control->Top - FileZillaHeight;
  133. }
  134. }
  135. ThirdPartyBox->VertScrollBar->Range = ThirdPartyBox->VertScrollBar->Range - FileZillaHeight;
  136. #endif
  137. #ifdef NO_COMPONENTS
  138. int ComponentsHeight = ThirdPartyBox->VertScrollBar->Range - Label1->Top;
  139. Label1->Visible = false;
  140. Label2->Visible = false;
  141. Toolbar2000HomepageLabel->Visible = false;
  142. Label5->Visible = false;
  143. Label6->Visible = false;
  144. TBXHomepageLabel->Visible = false;
  145. Label8->Visible = false;
  146. Label10->Visible = false;
  147. ThirdPartyBox->VertScrollBar->Range = ThirdPartyBox->VertScrollBar->Range - ComponentsHeight;
  148. #endif
  149. #ifdef NO_FILEZILLA
  150. #ifdef NO_COMPONENTS
  151. ThirdPartyBox->VertScrollBar->Range = ThirdPartyBox->ClientHeight;
  152. #endif
  153. #endif
  154. // VCL wrongly autosize these, even when AutoSize is off
  155. // WORKAROUND
  156. FixWrappedLabelSize(Label7);
  157. FixWrappedLabelSize(RegistrationSubjectLabel);
  158. FixWrappedLabelSize(OpenSSLVersionLabel);
  159. LicenseButton->Visible = AllowLicense;
  160. LoadData();
  161. }
  162. //---------------------------------------------------------------------------
  163. void __fastcall TAboutDialog::FixWrappedLabelSize(TLabel * Label)
  164. {
  165. Label->Width = Label->Parent->ClientWidth - (2 * Label->Left);
  166. }
  167. //---------------------------------------------------------------------------
  168. void __fastcall TAboutDialog::LoadData()
  169. {
  170. UnicodeString Version = FConfiguration->VersionStr;
  171. if (!FConfiguration->ProductName.IsEmpty() &&
  172. (FConfiguration->Version != FConfiguration->ProductVersion))
  173. {
  174. Version = FMTLOAD(ABOUT_BASED_ON_PRODUCT,
  175. (Version, FConfiguration->ProductName, FConfiguration->ProductVersion));
  176. }
  177. VersionLabel->Caption = Version;
  178. }
  179. //---------------------------------------------------------------------------
  180. void __fastcall TAboutDialog::PuttyLicenseLabelClick(TObject * /*Sender*/)
  181. {
  182. OpenBrowser(LoadStr(PUTTY_LICENSE_URL));
  183. }
  184. //---------------------------------------------------------------------------
  185. void __fastcall TAboutDialog::LicenseButtonClick(TObject * /*Sender*/)
  186. {
  187. DoProductLicense();
  188. }
  189. //---------------------------------------------------------------------------
  190. void __fastcall TAboutDialog::HelpButtonClick(TObject * /*Sender*/)
  191. {
  192. FormHelp(this);
  193. }
  194. //---------------------------------------------------------------------------
  195. void __fastcall TAboutDialog::FirstScrollingControlEnter(TObject * /*Sender*/)
  196. {
  197. ThirdPartyBox->VertScrollBar->Position = 0;
  198. }
  199. //---------------------------------------------------------------------------
  200. void __fastcall TAboutDialog::LastScrollingControlEnter(TObject * /*Sender*/)
  201. {
  202. ThirdPartyBox->VertScrollBar->Position =
  203. ThirdPartyBox->VertScrollBar->Range - ThirdPartyBox->ClientHeight;
  204. }
  205. //---------------------------------------------------------------------------
  206. void __fastcall TAboutDialog::RegistrationProductIdLabelClick(
  207. TObject * /*Sender*/)
  208. {
  209. if (FOnRegistrationLink != NULL)
  210. {
  211. FOnRegistrationLink(this);
  212. }
  213. }
  214. //---------------------------------------------------------------------------
  215. void __fastcall TAboutDialog::OKButtonMouseDown(TObject * /*Sender*/,
  216. TMouseButton Button, TShiftState Shift, int /*X*/, int /*Y*/)
  217. {
  218. if ((Button == mbRight) && Shift.Contains(ssAlt))
  219. {
  220. ACCESS_VIOLATION_TEST;
  221. }
  222. }
  223. //---------------------------------------------------------------------------