CreateDirectory.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. //---------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include <CoreMain.h>
  5. #include <Configuration.h>
  6. #include <RemoteFiles.h>
  7. #include <VCLCommon.h>
  8. #include <TextsWin.h>
  9. #include <Common.h>
  10. #include <WinInterface.h>
  11. #include <Tools.h>
  12. #include "CreateDirectory.h"
  13. //---------------------------------------------------------------------
  14. #pragma link "RightsExt"
  15. #pragma link "Rights"
  16. #ifndef NO_RESOURCES
  17. #pragma resource "*.dfm"
  18. #endif
  19. //---------------------------------------------------------------------
  20. bool __fastcall DoCreateDirectoryDialog(UnicodeString & Directory,
  21. TRemoteProperties * Properties, bool & SaveSettings)
  22. {
  23. bool Result;
  24. TCreateDirectoryDialog * Dialog = new TCreateDirectoryDialog(Application);
  25. try
  26. {
  27. Result = Dialog->Execute(Directory, Properties, SaveSettings);
  28. }
  29. __finally
  30. {
  31. delete Dialog;
  32. }
  33. return Result;
  34. }
  35. //---------------------------------------------------------------------
  36. __fastcall TCreateDirectoryDialog::TCreateDirectoryDialog(TComponent * AOwner):
  37. TForm(AOwner)
  38. {
  39. UseSystemSettings(this);
  40. RightsFrame->AllowAddXToDirectories = false;
  41. }
  42. //---------------------------------------------------------------------
  43. __fastcall TCreateDirectoryDialog::~TCreateDirectoryDialog()
  44. {
  45. }
  46. //---------------------------------------------------------------------------
  47. void __fastcall TCreateDirectoryDialog::ControlChange(TObject * /*Sender*/)
  48. {
  49. UpdateControls();
  50. }
  51. //---------------------------------------------------------------------------
  52. void __fastcall TCreateDirectoryDialog::UpdateControls()
  53. {
  54. EnableControl(OKBtn, !DirectoryEdit->Text.Trim().IsEmpty());
  55. EnableControl(RightsFrame, SetRightsCheck->Checked);
  56. }
  57. //---------------------------------------------------------------------------
  58. bool __fastcall TCreateDirectoryDialog::Execute(UnicodeString & Directory,
  59. TRemoteProperties * Properties, bool & SaveSettings)
  60. {
  61. DirectoryEdit->Text = Directory;
  62. SaveSettingsCheck->Checked = SaveSettings;
  63. if (Properties != NULL)
  64. {
  65. bool SetRights = Properties->Valid.Contains(vpRights);
  66. SetRightsCheck->Checked = SetRights;
  67. // expect sensible value even if rights are not set valid
  68. RightsFrame->Rights = Properties->Rights;
  69. }
  70. bool Result = (ShowModal() == DefaultResult(this));
  71. if (Result)
  72. {
  73. Directory = DirectoryEdit->Text;
  74. SaveSettings = SaveSettingsCheck->Checked;
  75. if (Properties != NULL)
  76. {
  77. if (SetRightsCheck->Checked)
  78. {
  79. Properties->Valid = Properties->Valid << vpRights;
  80. Properties->Rights = RightsFrame->Rights;
  81. }
  82. else
  83. {
  84. Properties->Valid = Properties->Valid >> vpRights;
  85. }
  86. }
  87. }
  88. return Result;
  89. }
  90. //---------------------------------------------------------------------------
  91. void __fastcall TCreateDirectoryDialog::DirectoryEditChange(TObject * /*Sender*/)
  92. {
  93. UpdateControls();
  94. }
  95. //---------------------------------------------------------------------------
  96. void __fastcall TCreateDirectoryDialog::FormShow(TObject * /*Sender*/)
  97. {
  98. InstallPathWordBreakProc(DirectoryEdit);
  99. UpdateControls();
  100. }
  101. //---------------------------------------------------------------------------
  102. void __fastcall TCreateDirectoryDialog::HelpButtonClick(TObject * /*Sender*/)
  103. {
  104. FormHelp(this);
  105. }
  106. //---------------------------------------------------------------------------
  107. void __fastcall TCreateDirectoryDialog::FormCloseQuery(TObject * /*Sender*/,
  108. bool & /*CanClose*/)
  109. {
  110. if (ModalResult == DefaultResult(this))
  111. {
  112. ExitActiveControl(this);
  113. }
  114. }
  115. //---------------------------------------------------------------------------