Licence.cpp 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include <Common.h>
  5. #include <TextsWin.h>
  6. #include <VCLCommon.h>
  7. #include "Licence.h"
  8. //---------------------------------------------------------------------------
  9. #pragma package(smart_init)
  10. #pragma resource "*.dfm"
  11. //---------------------------------------------------------------------------
  12. int LicenceStr[2] = { LICENCE, LICENCE_PUTTY };
  13. int LicenceCount[2] = { 17, 2 };
  14. //---------------------------------------------------------------------------
  15. void __fastcall DoLicenceDialog(TLicence Licence)
  16. {
  17. TLicenceDialog *LicenceDialog = NULL;
  18. try
  19. {
  20. LicenceDialog = new TLicenceDialog(Application);
  21. LicenceDialog->Licence = Licence;
  22. LicenceDialog->ShowModal();
  23. }
  24. __finally
  25. {
  26. delete LicenceDialog;
  27. }
  28. }
  29. //---------------------------------------------------------------------------
  30. void __fastcall DoLicenceDialog(const AnsiString LicenceText)
  31. {
  32. TLicenceDialog *LicenceDialog = NULL;
  33. try
  34. {
  35. LicenceDialog = new TLicenceDialog(Application);
  36. LicenceDialog->LicenceText = LicenceText;
  37. LicenceDialog->ShowModal();
  38. }
  39. __finally
  40. {
  41. delete LicenceDialog;
  42. }
  43. }
  44. //---------------------------------------------------------------------------
  45. __fastcall TLicenceDialog::TLicenceDialog(TComponent* Owner)
  46. : TForm(Owner)
  47. {
  48. FLicence = lcNoLicence;
  49. UseSystemSettings(this);
  50. }
  51. //---------------------------------------------------------------------------
  52. void __fastcall TLicenceDialog::SetLicence(TLicence value)
  53. {
  54. if (FLicence != value)
  55. {
  56. FLicence = value;
  57. TStrings * LicenceList = new TStringList();
  58. AnsiString ALicence = LoadStr(LicenceStr[FLicence]);
  59. for (Integer i = 1; i < LicenceCount[FLicence]; i++)
  60. {
  61. ALicence += LoadStr(LicenceStr[FLicence] + i);
  62. }
  63. LicenceList->Text = ALicence;
  64. assert(LicenceList->Count > 0);
  65. Caption = FMTLOAD(LICENCE_CAPTION, (LicenceList->Strings[0]));
  66. LicenceList->Delete(0);
  67. LicenceText = LicenceList->Text;
  68. }
  69. }
  70. //---------------------------------------------------------------------------
  71. void __fastcall TLicenceDialog::SetLicenceText(AnsiString value)
  72. {
  73. LicenceMemo->Lines->Text = value;
  74. }
  75. //---------------------------------------------------------------------------
  76. AnsiString __fastcall TLicenceDialog::GetLicenceText()
  77. {
  78. return LicenceMemo->Lines->Text;
  79. }