WinConfiguration.cpp 57 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "WinConfiguration.h"
  5. #include "Common.h"
  6. #include "Exceptions.h"
  7. #include "Bookmarks.h"
  8. #include "Terminal.h"
  9. #include "TextsWin.h"
  10. #include "WinInterface.h"
  11. #include "GUITools.h"
  12. #include "Tools.h"
  13. #include <VCLCommon.h>
  14. #include <ResourceModule.hpp>
  15. #include <LanguagesDEPfix.hpp>
  16. #include <InitGUID.h>
  17. #include <DragExt.h>
  18. //---------------------------------------------------------------------------
  19. #pragma package(smart_init)
  20. //---------------------------------------------------------------------------
  21. __fastcall TEditorPreferences::TEditorPreferences()
  22. {
  23. FData.FileMask = "*.*";
  24. FData.Editor = edInternal;
  25. FData.ExternalEditor = "";
  26. FData.ExternalEditorText = true;
  27. FData.MDIExternalEditor = false;
  28. FData.DetectMDIExternalEditor = true;
  29. }
  30. //---------------------------------------------------------------------------
  31. __fastcall TEditorPreferences::TEditorPreferences(const TEditorPreferences & Source)
  32. {
  33. FData.FileMask = Source.FData.FileMask;
  34. FData.Editor = Source.FData.Editor;
  35. FData.ExternalEditor = Source.FData.ExternalEditor;
  36. FData.ExternalEditorText = Source.FData.ExternalEditorText;
  37. FData.MDIExternalEditor = Source.FData.MDIExternalEditor;
  38. FData.DetectMDIExternalEditor = Source.FData.DetectMDIExternalEditor;
  39. }
  40. //---------------------------------------------------------------------------
  41. #define C(Property) (Property == rhp.Property)
  42. bool __fastcall TEditorPreferences::operator==(const TEditorPreferences & rhp) const
  43. {
  44. return
  45. C(FData.FileMask) &&
  46. C(FData.Editor) &&
  47. C(FData.ExternalEditor) &&
  48. C(FData.ExternalEditorText) &&
  49. C(FData.MDIExternalEditor) &&
  50. C(FData.DetectMDIExternalEditor) &&
  51. true;
  52. }
  53. #undef C
  54. //---------------------------------------------------------------------------
  55. bool __fastcall TEditorPreferences::Matches(const AnsiString FileName,
  56. bool Local, const TFileMasks::TParams & Params) const
  57. {
  58. return FData.FileMask.Matches(FileName, Local, false, &Params);
  59. }
  60. //---------------------------------------------------------------------------
  61. void __fastcall TEditorPreferences::LegacyDefaults()
  62. {
  63. FData.ExternalEditor = "notepad.exe";
  64. }
  65. //---------------------------------------------------------------------------
  66. void __fastcall TEditorPreferences::Load(THierarchicalStorage * Storage, bool Legacy)
  67. {
  68. if (!Legacy)
  69. {
  70. FData.FileMask = Storage->ReadString("FileMask", FData.FileMask.Masks);
  71. }
  72. FData.Editor = (TEditor)Storage->ReadInteger("Editor", FData.Editor);
  73. FData.ExternalEditor = Storage->ReadString("ExternalEditor", FData.ExternalEditor);
  74. FData.ExternalEditorText = Storage->ReadBool("ExternalEditorText", FData.ExternalEditorText);
  75. FData.MDIExternalEditor = Storage->ReadBool("MDIExternalEditor", FData.MDIExternalEditor);
  76. FData.DetectMDIExternalEditor = Storage->ReadBool("DetectMDIExternalEditor", FData.DetectMDIExternalEditor);
  77. }
  78. //---------------------------------------------------------------------------
  79. void __fastcall TEditorPreferences::Save(THierarchicalStorage * Storage) const
  80. {
  81. Storage->WriteString("FileMask", FData.FileMask.Masks);
  82. Storage->WriteInteger("Editor", FData.Editor);
  83. Storage->WriteString("ExternalEditor", FData.ExternalEditor);
  84. Storage->WriteBool("ExternalEditorText", FData.ExternalEditorText);
  85. Storage->WriteBool("MDIExternalEditor", FData.MDIExternalEditor);
  86. Storage->WriteBool("DetectMDIExternalEditor", FData.DetectMDIExternalEditor);
  87. }
  88. //---------------------------------------------------------------------------
  89. AnsiString __fastcall TEditorPreferences::GetName() const
  90. {
  91. if (FName.IsEmpty())
  92. {
  93. if (FData.Editor == edInternal)
  94. {
  95. FName = StripHotkey(LoadStr(INTERNAL_EDITOR_NAME));
  96. }
  97. else
  98. {
  99. AnsiString Program, Params, Dir;
  100. AnsiString ExternalEditor = FData.ExternalEditor;
  101. ReformatFileNameCommand(ExternalEditor);
  102. SplitCommand(ExternalEditor, Program, Params, Dir);
  103. FName = ExtractFileName(Program);
  104. int P = FName.LastDelimiter(".");
  105. if (P > 0)
  106. {
  107. FName.SetLength(P - 1);
  108. }
  109. if (FName.ByteType(1) == mbSingleByte)
  110. {
  111. if (FName.UpperCase() == FName)
  112. {
  113. FName = FName.LowerCase();
  114. }
  115. if (FName.LowerCase() == FName)
  116. {
  117. FName = FName.SubString(1, 1).UpperCase() +
  118. FName.SubString(2, FName.Length() - 1);
  119. }
  120. }
  121. }
  122. }
  123. return FName;
  124. }
  125. //---------------------------------------------------------------------------
  126. //---------------------------------------------------------------------------
  127. __fastcall TEditorList::TEditorList()
  128. {
  129. Init();
  130. }
  131. //---------------------------------------------------------------------------
  132. void __fastcall TEditorList::Init()
  133. {
  134. FEditors = new TList();
  135. FModified = false;
  136. }
  137. //---------------------------------------------------------------------------
  138. __fastcall TEditorList::~TEditorList()
  139. {
  140. Clear();
  141. delete FEditors;
  142. }
  143. //---------------------------------------------------------------------
  144. void __fastcall TEditorList::Modify()
  145. {
  146. FModified = true;
  147. }
  148. //---------------------------------------------------------------------------
  149. void __fastcall TEditorList::Saved()
  150. {
  151. FModified = false;
  152. }
  153. //---------------------------------------------------------------------------
  154. void __fastcall TEditorList::operator=(const TEditorList & rhl)
  155. {
  156. Clear();
  157. for (int Index = 0; Index < rhl.Count; Index++)
  158. {
  159. Add(new TEditorPreferences(*rhl.Editors[Index]));
  160. }
  161. // there should be comparison of with the assigned list, be we rely on caller
  162. // to do it instead (TWinConfiguration::SetEditorList)
  163. Modify();
  164. }
  165. //---------------------------------------------------------------------------
  166. bool __fastcall TEditorList::operator==(const TEditorList & rhl) const
  167. {
  168. bool Result = (Count == rhl.Count);
  169. if (Result)
  170. {
  171. int i = 0;
  172. while ((i < Count) && Result)
  173. {
  174. Result = (*Editors[i]) == (*rhl.Editors[i]);
  175. i++;
  176. }
  177. }
  178. return Result;
  179. }
  180. //---------------------------------------------------------------------------
  181. void __fastcall TEditorList::Clear()
  182. {
  183. for (int i = 0; i < Count; i++)
  184. {
  185. delete Editors[i];
  186. }
  187. FEditors->Clear();
  188. }
  189. //---------------------------------------------------------------------------
  190. void __fastcall TEditorList::Add(TEditorPreferences * Editor)
  191. {
  192. Insert(Count, Editor);
  193. }
  194. //---------------------------------------------------------------------------
  195. void __fastcall TEditorList::Insert(int Index, TEditorPreferences * Editor)
  196. {
  197. FEditors->Insert(Index, reinterpret_cast<TObject *>(Editor));
  198. Modify();
  199. }
  200. //---------------------------------------------------------------------------
  201. void __fastcall TEditorList::Change(int Index, TEditorPreferences * Editor)
  202. {
  203. if (!((*Editors[Index]) == *Editor))
  204. {
  205. delete Editors[Index];
  206. FEditors->Items[Index] = (reinterpret_cast<TObject *>(Editor));
  207. Modify();
  208. }
  209. else
  210. {
  211. delete Editor;
  212. }
  213. }
  214. //---------------------------------------------------------------------------
  215. void __fastcall TEditorList::Move(int CurIndex, int NewIndex)
  216. {
  217. if (CurIndex != NewIndex)
  218. {
  219. FEditors->Move(CurIndex, NewIndex);
  220. Modify();
  221. }
  222. }
  223. //---------------------------------------------------------------------------
  224. void __fastcall TEditorList::Delete(int Index)
  225. {
  226. assert((Index >= 0) && (Index < Count));
  227. delete Editors[Index];
  228. FEditors->Delete(Index);
  229. Modify();
  230. }
  231. //---------------------------------------------------------------------------
  232. const TEditorPreferences * __fastcall TEditorList::Find(
  233. const AnsiString FileName, bool Local, const TFileMasks::TParams & Params) const
  234. {
  235. const TEditorPreferences * Result = NULL;
  236. int i = 0;
  237. while ((i < FEditors->Count) && (Result == NULL))
  238. {
  239. Result = Editors[i];
  240. if (!Result->Matches(FileName, Local, Params))
  241. {
  242. Result = NULL;
  243. }
  244. i++;
  245. }
  246. return Result;
  247. }
  248. //---------------------------------------------------------------------------
  249. void __fastcall TEditorList::Load(THierarchicalStorage * Storage)
  250. {
  251. int Index = 0;
  252. bool Next;
  253. do
  254. {
  255. AnsiString Name = IntToStr(Index);
  256. TEditorPreferences * Editor = NULL;
  257. try
  258. {
  259. Next = Storage->OpenSubKey(Name, false);
  260. if (Next)
  261. {
  262. try
  263. {
  264. Editor = new TEditorPreferences();
  265. Editor->Load(Storage, false);
  266. }
  267. __finally
  268. {
  269. Storage->CloseSubKey();
  270. }
  271. }
  272. }
  273. catch(...)
  274. {
  275. delete Editor;
  276. throw;
  277. }
  278. if (Editor != NULL)
  279. {
  280. FEditors->Add(reinterpret_cast<TObject *>(Editor));
  281. }
  282. Index++;
  283. }
  284. while (Next);
  285. FModified = false;
  286. }
  287. //---------------------------------------------------------------------------
  288. void __fastcall TEditorList::Save(THierarchicalStorage * Storage) const
  289. {
  290. Storage->ClearSubKeys();
  291. for (int Index = 0; Index < Count; Index++)
  292. {
  293. if (Storage->OpenSubKey(IntToStr(Index), true))
  294. {
  295. try
  296. {
  297. Editors[Index]->Save(Storage);
  298. }
  299. __finally
  300. {
  301. Storage->CloseSubKey();
  302. }
  303. }
  304. }
  305. }
  306. //---------------------------------------------------------------------------
  307. int __fastcall TEditorList::GetCount() const
  308. {
  309. int X = FEditors->Count;
  310. return X;
  311. }
  312. //---------------------------------------------------------------------------
  313. const TEditorPreferences * __fastcall TEditorList::GetEditor(int Index) const
  314. {
  315. return reinterpret_cast<TEditorPreferences *>(FEditors->Items[Index]);
  316. }
  317. //---------------------------------------------------------------------------
  318. //---------------------------------------------------------------------------
  319. __fastcall TWinConfiguration::TWinConfiguration(): TCustomWinConfiguration()
  320. {
  321. FInvalidDefaultTranslationMessage = "";
  322. FDDExtInstalled = -1;
  323. FBookmarks = new TBookmarks();
  324. FCustomCommands = new TCustomCommands();
  325. FEditorList = new TEditorList();
  326. Default();
  327. try
  328. {
  329. CheckTranslationVersion(::GetResourceModule(ModuleFileName().c_str()), true);
  330. }
  331. catch(Exception & E)
  332. {
  333. FInvalidDefaultTranslationMessage = E.Message;
  334. }
  335. }
  336. //---------------------------------------------------------------------------
  337. __fastcall TWinConfiguration::~TWinConfiguration()
  338. {
  339. if (!FTemporarySessionFile.IsEmpty()) DeleteFile(FTemporarySessionFile);
  340. ClearTemporaryLoginData();
  341. delete FBookmarks;
  342. delete FCustomCommands;
  343. delete FEditorList;
  344. }
  345. //---------------------------------------------------------------------------
  346. void __fastcall TWinConfiguration::Default()
  347. {
  348. FCustomCommandsDefaults = true;
  349. TCustomWinConfiguration::Default();
  350. FDDAllowMove = false;
  351. FDDAllowMoveInit = false;
  352. FDDTransferConfirmation = true;
  353. FDDTemporaryDirectory = "";
  354. FDDWarnLackOfTempSpace = true;
  355. FDDWarnLackOfTempSpaceRatio = 1.1;
  356. FDDExtEnabled = DDExtInstalled;
  357. FDDExtTimeout = 1000;
  358. FDeleteToRecycleBin = true;
  359. FSelectDirectories = false;
  360. FSelectMask = "*.*";
  361. FShowHiddenFiles = true;
  362. FShowInaccesibleDirectories = true;
  363. FConfirmTransferring = true;
  364. FConfirmDeleting = true;
  365. FConfirmRecycling = true;
  366. FConfirmClosingSession = true;
  367. FConfirmExitOnCompletion = true;
  368. FDoubleClickAction = dcaEdit;
  369. FCopyOnDoubleClickConfirmation = false;
  370. FDimmHiddenFiles = true;
  371. FAutoStartSession = "";
  372. FExpertMode = true;
  373. FUseLocationProfiles = false;
  374. FDefaultDirIsHome = true;
  375. FDDDeleteDelay = 120;
  376. FTemporaryDirectoryCleanup = true;
  377. FConfirmTemporaryDirectoryCleanup = true;
  378. FPreservePanelState = true;
  379. FTheme = "OfficeXP";
  380. FPathInCaption = picShort;
  381. FMinimizeToTray = false;
  382. FBalloonNotifications = true;
  383. FNotificationsTimeout = 10;
  384. FNotificationsStickTime = 2;
  385. FCopyParamAutoSelectNotice = true;
  386. FSessionToolbarAutoShown = false;
  387. FLockToolbars = false;
  388. FAutoOpenInPutty = false;
  389. FEditor.FontName = "Courier New";
  390. FEditor.FontHeight = -12;
  391. FEditor.FontStyle = 0;
  392. FEditor.FontCharset = DEFAULT_CHARSET;
  393. FEditor.WordWrap = false;
  394. FEditor.FindText = "";
  395. FEditor.ReplaceText = "";
  396. FEditor.FindMatchCase = false;
  397. FEditor.FindWholeWord = false;
  398. FEditor.FindDown = true;
  399. FEditor.TabSize = 7;
  400. FEditor.MaxEditors = 500;
  401. FEditor.EarlyClose = 2; // seconds
  402. FQueueView.Height = 100;
  403. FQueueView.Layout = "70,160,160,80,80,80";
  404. FQueueView.Show = qvHideWhenEmpty;
  405. FQueueView.LastHideShow = qvHideWhenEmpty;
  406. FQueueView.ToolBar = false;
  407. FUpdates.Period = 0;
  408. FUpdates.LastCheck = 0;
  409. FUpdates.HaveResults = false;
  410. FUpdates.ShownResults = false;
  411. // for backward compatibility the default is decided based on value of ProxyHost
  412. FUpdates.ConnectionType = (TConnectionType)-1;
  413. FUpdates.ProxyHost = ""; // keep empty (see above)
  414. FUpdates.ProxyPort = 8080;
  415. FUpdates.Results.Reset();
  416. FLogWindowOnStartup = true;
  417. FLogWindowParams = "-1;-1;500;400";
  418. FScpExplorer.WindowParams = "-1;-1;600;400;0";
  419. FScpExplorer.DirViewParams = "0;1;0|150,1;70,1;101,1;79,1;62,1;55,1;20,0;150,0;125,0|0;1;8;2;3;4;5;6;7";
  420. FScpExplorer.ToolbarsLayout =
  421. "Queue_Visible=1,Queue_LastDock=QueueDock,Queue_DockRow=0,Queue_DockPos=-1,Queue_FloatLeft=0,Queue_FloatTop=0,Queue_FloatRightX=0,"
  422. "Menu_Visible=1,Menu_DockedTo=TopDock,Menu_LastDock=TopDock,Menu_DockRow=0,Menu_DockPos=0,Menu_FloatLeft=0,Menu_FloatTop=0,Menu_FloatRightX=0,"
  423. "Buttons_Visible=1,Buttons_DockedTo=TopDock,Buttons_LastDock=TopDock,Buttons_DockRow=2,Buttons_DockPos=0,Buttons_FloatLeft=0,Buttons_FloatTop=0,Buttons_FloatRightX=0,"
  424. "Selection_Visible=0,Selection_DockedTo=TopDock,Selection_LastDock=TopDock,Selection_DockRow=3,Selection_DockPos=0,Selection_FloatLeft=227,Selection_FloatTop=445,Selection_FloatRightX=0,"
  425. "Session_Visible=0,Session_DockedTo=TopDock,Session_LastDock=TopDock,Session_DockRow=6,Session_DockPos=0,Session_FloatLeft=39,Session_FloatTop=160,Session_FloatRightX=0,"
  426. "Preferences_Visible=1,Preferences_DockedTo=TopDock,Preferences_LastDock=TopDock,Preferences_DockRow=4,Preferences_DockPos=0,Preferences_FloatLeft=0,Preferences_FloatTop=0,Preferences_FloatRightX=0,"
  427. "Sort_Visible=0,Sort_DockedTo=TopDock,Sort_LastDock=TopDock,Sort_DockRow=5,Sort_DockPos=0,Sort_FloatLeft=0,Sort_FloatTop=0,Sort_FloatRightX=0,"
  428. "Address_Visible=1,Address_DockedTo=TopDock,Address_LastDock=TopDock,Address_DockRow=1,Address_DockPos=0,Address_FloatLeft=0,Address_FloatTop=0,Address_FloatRightX=0,"
  429. "Updates_Visible=1,Updates_DockedTo=TopDock,Updates_LastDock=TopDock,Updates_DockRow=4,Updates_DockPos=302,Updates_FloatLeft=0,Updates_FloatTop=0,Updates_FloatRightX=0,"
  430. "Transfer_Visible=1,Transfer_DockedTo=TopDock,Transfer_LastDock=TopDock,Transfer_DockRow=4,Transfer_DockPos=155,Transfer_FloatLeft=0,Transfer_FloatTop=0,Transfer_FloatRightX=0"
  431. "CustomCommands_Visible=0,CustomCommands_DockedTo=TopDock,CustomCommands_LastDock=TopDock,CustomCommands_DockRow=7,CustomCommands_DockPos=0,CustomCommands_FloatLeft=0,CustomCommands_FloatTop=0,CustomCommands_FloatRightX=0";
  432. FScpExplorer.StatusBar = true;
  433. AnsiString PersonalFolder;
  434. ::SpecialFolderLocation(CSIDL_PERSONAL, PersonalFolder);
  435. FScpExplorer.LastLocalTargetDirectory = PersonalFolder;
  436. FScpExplorer.ViewStyle = 0; /* vsIcon */
  437. FScpExplorer.ShowFullAddress = true;
  438. FScpExplorer.DriveView = true;
  439. FScpExplorer.DriveViewWidth = 180;
  440. FScpCommander.WindowParams = ((Screen->Width > 900) && (Screen->Height > 700)) ?
  441. "-1;-1;850;650;0" : "-1;-1;600;400;0";
  442. FScpCommander.LocalPanelWidth = 0.5;
  443. FScpCommander.SwappedPanels = false;
  444. FScpCommander.StatusBar = true;
  445. FScpCommander.NortonLikeMode = nlOn;
  446. FScpCommander.PreserveLocalDirectory = false;
  447. // Toolbar_FloatRightX=1 makes keybar apper initialy "in column" when undocked
  448. FScpCommander.ToolbarsLayout =
  449. "Queue_Visible=1,Queue_LastDock=QueueDock,Queue_DockRow=0,Queue_DockPos=-1,Queue_FloatLeft=0,Queue_FloatTop=0,Queue_FloatRightX=0,"
  450. "Session_Visible=0,Session_DockedTo=TopDock,Session_LastDock=TopDock,Session_DockRow=1,Session_DockPos=602,Session_FloatLeft=380,Session_FloatTop=197,Session_FloatRightX=0,"
  451. "Preferences_Visible=1,Preferences_DockedTo=TopDock,Preferences_LastDock=TopDock,Preferences_DockRow=1,Preferences_DockPos=0,Preferences_FloatLeft=0,Preferences_FloatTop=0,Preferences_FloatRightX=0,"
  452. "Selection_Visible=1,Selection_DockedTo=TopDock,Selection_LastDock=TopDock,Selection_DockRow=1,Selection_DockPos=257,Selection_FloatLeft=0,Selection_FloatTop=0,Selection_FloatRightX=0,"
  453. "Command_Visible=0,Command_DockedTo=TopDock,Command_LastDock=TopDock,Command_DockRow=2,Command_DockPos=0,Command_FloatLeft=0,Command_FloatTop=0,Command_FloatRightX=0,"
  454. "Sort_Visible=0,Sort_DockedTo=TopDock,Sort_LastDock=TopDock,Sort_DockRow=3,Sort_DockPos=0,Sort_FloatLeft=0,Sort_FloatTop=0,Sort_FloatRightX=0,"
  455. "Commands_Visible=1,Commands_DockedTo=TopDock,Commands_LastDock=TopDock,Commands_DockRow=1,Commands_DockPos=97,Commands_FloatLeft=0,Commands_FloatTop=0,Commands_FloatRightX=0,"
  456. "Menu_Visible=1,Menu_DockedTo=TopDock,Menu_LastDock=TopDock,Menu_DockRow=0,Menu_DockPos=0,Menu_FloatLeft=0,Menu_FloatTop=0,Menu_FloatRightX=0,"
  457. "Updates_Visible=1,Updates_DockedTo=TopDock,Updates_LastDock=TopDock,Updates_DockRow=1,Updates_DockPos=557,Updates_FloatLeft=0,Updates_FloatTop=0,Updates_FloatRightX=0,"
  458. "Transfer_Visible=1,Transfer_DockedTo=TopDock,Transfer_LastDock=TopDock,Transfer_DockRow=1,Transfer_DockPos=411,Transfer_FloatLeft=0,Transfer_FloatTop=0,Transfer_FloatRightX=0,"
  459. "UploadDownload_Visible=0,UploadDownload_DockedTo=TopDock,UploadDownload_LastDock=TopDock,UploadDownload_DockRow=4,UploadDownload_DockPos=0,UploadDownload_FloatLeft=0,UploadDownload_FloatTop=0,UploadDownload_FloatRightX=0,"
  460. "CustomCommands_Visible=0,CustomCommands_DockedTo=TopDock,CustomCommands_LastDock=TopDock,CustomCommands_DockRow=5,CustomCommands_DockPos=0,CustomCommands_FloatLeft=0,CustomCommands_FloatTop=0,CustomCommands_FloatRightX=0,"
  461. "RemotePath_Visible=1,RemotePath_DockedTo=RemoteTopDock,RemotePath_LastDock=RemoteTopDock,RemotePath_DockRow=0,RemotePath_DockPos=0,RemotePath_FloatLeft=0,RemotePath_FloatTop=0,RemotePath_FloatRightX=0,"
  462. "RemoteHistory_Visible=1,RemoteHistory_DockedTo=RemoteTopDock,RemoteHistory_LastDock=RemoteTopDock,RemoteHistory_DockRow=0,RemoteHistory_DockPos=208,RemoteHistory_FloatLeft=0,RemoteHistory_FloatTop=0,RemoteHistory_FloatRightX=0,"
  463. "RemoteNavigation_Visible=1,RemoteNavigation_DockedTo=RemoteTopDock,RemoteNavigation_LastDock=RemoteTopDock,RemoteNavigation_DockRow=0,RemoteNavigation_DockPos=288,RemoteNavigation_FloatLeft=0,RemoteNavigation_FloatTop=0,RemoteNavigation_FloatRightX=0,"
  464. "LocalPath_Visible=1,LocalPath_DockedTo=LocalTopDock,LocalPath_LastDock=LocalTopDock,LocalPath_DockRow=0,LocalPath_DockPos=0,LocalPath_FloatLeft=0,LocalPath_FloatTop=0,LocalPath_FloatRightX=0,"
  465. "LocalHistory_Visible=1,LocalHistory_DockedTo=LocalTopDock,LocalHistory_LastDock=LocalTopDock,LocalHistory_DockRow=0,LocalHistory_DockPos=207,LocalHistory_FloatLeft=0,LocalHistory_FloatTop=0,LocalHistory_FloatRightX=0,"
  466. "LocalNavigation_Visible=1,LocalNavigation_DockedTo=LocalTopDock,LocalNavigation_LastDock=LocalTopDock,LocalNavigation_DockRow=0,LocalNavigation_DockPos=287,LocalNavigation_FloatLeft=0,LocalNavigation_FloatTop=0,LocalNavigation_FloatRightX=0,"
  467. "Toolbar_Visible=1,Toolbar_DockedTo=BottomDock,Toolbar_LastDock=BottomDock,Toolbar_DockRow=1,Toolbar_DockPos=0,Toolbar_FloatLeft=0,Toolbar_FloatTop=0,Toolbar_FloatRightX=1,"
  468. "CommandLine_Visible=0,CommandLine_DockedTo=BottomDock,CommandLine_LastDock=BottomDock,CommandLine_DockRow=0,CommandLine_DockPos=0,CommandLine_FloatLeft=0,CommandLine_FloatTop=0,CommandLine_FloatRightX=0";
  469. FScpCommander.CurrentPanel = osLocal;
  470. FScpCommander.CompareByTime = true;
  471. FScpCommander.CompareBySize = false;
  472. FScpCommander.FullRowSelect = true;
  473. FScpCommander.RemotePanel.DirViewParams = "0;1;0|150,1;70,1;101,1;79,1;62,1;55,0;20,0;150,0;125,0|0;1;8;2;3;4;5;6;7";
  474. FScpCommander.RemotePanel.StatusBar = true;
  475. FScpCommander.RemotePanel.DriveView = false;
  476. FScpCommander.RemotePanel.DriveViewHeight = 100;
  477. FScpCommander.LocalPanel.DirViewParams = "0;1;0|150,1;70,1;101,1;79,1;62,1;55,0|0;1;2;3;4;5";
  478. FScpCommander.LocalPanel.StatusBar = true;
  479. FScpCommander.LocalPanel.DriveView = false;
  480. FScpCommander.LocalPanel.DriveViewHeight = 100;
  481. FBookmarks->Clear();
  482. }
  483. //---------------------------------------------------------------------------
  484. void __fastcall TWinConfiguration::DefaultLocalized()
  485. {
  486. TGUIConfiguration::DefaultLocalized();
  487. if (FCustomCommandsDefaults)
  488. {
  489. FCustomCommands->Clear();
  490. FCustomCommands->Values[LoadStr(CUSTOM_COMMAND_EXECUTE)] = "\"./!\"";
  491. FCustomCommands->Params[LoadStr(CUSTOM_COMMAND_EXECUTE)] = 0;
  492. FCustomCommands->Values[LoadStr(CUSTOM_COMMAND_TOUCH)] = "touch \"!\"";
  493. FCustomCommands->Params[LoadStr(CUSTOM_COMMAND_TOUCH)] = ccApplyToDirectories | ccRecursive;
  494. FCustomCommands->Values[LoadStr(CUSTOM_COMMAND_TAR)] =
  495. FORMAT("tar -cz -f \"!?%s?archive.tgz!\" !&",
  496. (LoadStr(CUSTOM_COMMAND_TAR_ARCHIVE)));
  497. FCustomCommands->Params[LoadStr(CUSTOM_COMMAND_TAR)] = ccApplyToDirectories;
  498. FCustomCommands->Values[LoadStr(CUSTOM_COMMAND_UNTAR)] =
  499. FORMAT("tar -xz --directory=\"!?%s?.!\" -f \"!\"",
  500. (LoadStr(CUSTOM_COMMAND_UNTAR_DIRECTORY)));
  501. FCustomCommands->Params[LoadStr(CUSTOM_COMMAND_UNTAR)] = 0;
  502. FCustomCommands->Values[LoadStr(CUSTOM_COMMAND_GREP)] =
  503. FORMAT("grep \"!?%s?!\" !&", (LoadStr(CUSTOM_COMMAND_GREP_PATTERN)));
  504. FCustomCommands->Params[LoadStr(CUSTOM_COMMAND_GREP)] = ccShowResults;
  505. if (Win32Platform == VER_PLATFORM_WIN32_NT)
  506. {
  507. FCustomCommands->Values[LoadStr(CUSTOM_COMMAND_FC)] =
  508. "cmd /c fc \"!\" \"\!^!\" | more && pause";
  509. FCustomCommands->Params[LoadStr(CUSTOM_COMMAND_FC)] = ccLocal;
  510. }
  511. FCustomCommands->Values[LoadStr(CUSTOM_COMMAND_PRINT)] = "notepad.exe /p \"!\"";
  512. FCustomCommands->Params[LoadStr(CUSTOM_COMMAND_PRINT)] = ccLocal;
  513. FCustomCommandsDefaults = true;
  514. FCustomCommandsModified = false;
  515. }
  516. }
  517. //---------------------------------------------------------------------------
  518. bool __fastcall TWinConfiguration::DetectRegistryStorage(HKEY RootKey)
  519. {
  520. bool Result = false;
  521. TRegistryStorage * Storage = new TRegistryStorage(RegistryStorageKey, RootKey);
  522. try
  523. {
  524. if (Storage->OpenRootKey(false))
  525. {
  526. Result = true;
  527. Storage->CloseSubKey();
  528. }
  529. }
  530. __finally
  531. {
  532. delete Storage;
  533. }
  534. return Result;
  535. }
  536. //---------------------------------------------------------------------------
  537. bool __fastcall TWinConfiguration::CanWriteToStorage()
  538. {
  539. bool Result = false;
  540. try
  541. {
  542. THierarchicalStorage * Storage = CreateScpStorage(false);
  543. try
  544. {
  545. Storage->AccessMode = smReadWrite;
  546. if (Storage->OpenSubKey(ConfigurationSubKey, true))
  547. {
  548. Storage->WriteBool("WriteTest", true);
  549. Storage->DeleteValue("WriteTest");
  550. }
  551. }
  552. __finally
  553. {
  554. delete Storage;
  555. }
  556. Result = true;
  557. }
  558. catch(...)
  559. {
  560. }
  561. return Result;
  562. }
  563. //---------------------------------------------------------------------------
  564. TStorage __fastcall TWinConfiguration::GetStorage()
  565. {
  566. if (FStorage == stDetect)
  567. {
  568. if (FindResourceEx(NULL, RT_RCDATA, "WINSCP_SESSION",
  569. MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL)))
  570. {
  571. FTemporarySessionFile =
  572. IncludeTrailingBackslash(SystemTemporaryDirectory()) + "winscps.tmp";
  573. DumpResourceToFile("WINSCP_SESSION", FTemporarySessionFile);
  574. FEmbeddedSessions = true;
  575. FTemporaryKeyFile =
  576. IncludeTrailingBackslash(SystemTemporaryDirectory()) + "winscpk.tmp";
  577. if (!DumpResourceToFile("WINSCP_KEY", FTemporaryKeyFile))
  578. {
  579. FTemporaryKeyFile = "";
  580. }
  581. }
  582. FStorage = stIniFile;
  583. if (!FileExists(IniFileStorageName))
  584. {
  585. if (DetectRegistryStorage(HKEY_CURRENT_USER) ||
  586. DetectRegistryStorage(HKEY_LOCAL_MACHINE) ||
  587. !CanWriteToStorage())
  588. {
  589. FStorage = stRegistry;
  590. }
  591. }
  592. }
  593. return TCustomWinConfiguration::GetStorage();
  594. }
  595. //---------------------------------------------------------------------------
  596. void __fastcall TWinConfiguration::Saved()
  597. {
  598. TCustomWinConfiguration::Saved();
  599. FBookmarks->ModifyAll(false);
  600. FCustomCommandsModified = false;
  601. FEditorList->Saved();
  602. }
  603. //---------------------------------------------------------------------------
  604. THierarchicalStorage * TWinConfiguration::CreateScpStorage(bool SessionList)
  605. {
  606. if (SessionList && !FTemporarySessionFile.IsEmpty())
  607. {
  608. return new TIniFileStorage(FTemporarySessionFile);
  609. }
  610. else
  611. {
  612. return TCustomWinConfiguration::CreateScpStorage(SessionList);
  613. }
  614. }
  615. //---------------------------------------------------------------------------
  616. // duplicated from core\configuration.cpp
  617. #define LASTELEM(ELEM) \
  618. ELEM.SubString(ELEM.LastDelimiter(".>")+1, ELEM.Length() - ELEM.LastDelimiter(".>"))
  619. #define BLOCK(KEY, CANCREATE, BLOCK) \
  620. if (Storage->OpenSubKey(KEY, CANCREATE)) try { BLOCK } __finally { Storage->CloseSubKey(); }
  621. #define KEY(TYPE, VAR) KEYEX(TYPE, VAR, VAR)
  622. #define REGCONFIG(CANCREATE) \
  623. BLOCK("Interface", CANCREATE, \
  624. KEYEX(Integer,DoubleClickAction, CopyOnDoubleClick); \
  625. KEY(Bool, CopyOnDoubleClickConfirmation); \
  626. KEY(Bool, DDAllowMove); \
  627. KEY(Bool, DDAllowMoveInit); \
  628. KEY(Bool, DDTransferConfirmation); \
  629. KEY(String, DDTemporaryDirectory); \
  630. KEY(Bool, DDWarnLackOfTempSpace); \
  631. KEY(Float, DDWarnLackOfTempSpaceRatio); \
  632. KEY(Bool, DeleteToRecycleBin); \
  633. KEY(Bool, DimmHiddenFiles); \
  634. KEY(Bool, SelectDirectories); \
  635. KEY(String, SelectMask); \
  636. KEY(Bool, ShowHiddenFiles); \
  637. KEY(Bool, ShowInaccesibleDirectories); \
  638. KEY(Bool, ConfirmTransferring); \
  639. KEY(Bool, ConfirmDeleting); \
  640. KEY(Bool, ConfirmRecycling); \
  641. KEY(Bool, ConfirmClosingSession); \
  642. KEY(Bool, ConfirmExitOnCompletion); \
  643. KEY(String, AutoStartSession); \
  644. KEY(Bool, UseLocationProfiles); \
  645. KEY(Integer, LocaleSafe); \
  646. KEY(Bool, DDExtEnabled); \
  647. KEY(Integer, DDExtTimeout); \
  648. KEY(Bool, DefaultDirIsHome); \
  649. KEY(Bool, TemporaryDirectoryCleanup); \
  650. KEY(Bool, ConfirmTemporaryDirectoryCleanup); \
  651. KEY(Bool, PreservePanelState); \
  652. KEY(String, Theme); \
  653. KEY(Integer, PathInCaption); \
  654. KEY(Bool, MinimizeToTray); \
  655. KEY(Bool, BalloonNotifications); \
  656. KEY(Integer, NotificationsTimeout); \
  657. KEY(Integer, NotificationsStickTime); \
  658. KEY(Bool, CopyParamAutoSelectNotice); \
  659. KEY(Bool, SessionToolbarAutoShown); \
  660. KEY(Bool, LockToolbars); \
  661. KEY(Bool, AutoOpenInPutty); \
  662. KEY(Integer, LastMonitor); \
  663. ); \
  664. BLOCK("Interface\\Editor", CANCREATE, \
  665. KEY(String, Editor.FontName); \
  666. KEY(Integer, Editor.FontHeight); \
  667. KEY(Integer, Editor.FontStyle); \
  668. KEY(Integer, Editor.FontCharset); \
  669. KEY(Bool, Editor.WordWrap); \
  670. KEY(String, Editor.FindText); \
  671. KEY(String, Editor.ReplaceText); \
  672. KEY(Bool, Editor.FindMatchCase); \
  673. KEY(Bool, Editor.FindWholeWord); \
  674. KEY(Bool, Editor.FindDown); \
  675. KEY(Integer, Editor.TabSize); \
  676. KEY(Integer, Editor.MaxEditors); \
  677. KEY(Integer, Editor.EarlyClose); \
  678. ); \
  679. BLOCK("Interface\\QueueView", CANCREATE, \
  680. KEY(Integer, QueueView.Height); \
  681. KEY(String, QueueView.Layout); \
  682. KEY(Integer, QueueView.Show); \
  683. KEY(Integer, QueueView.LastHideShow); \
  684. KEY(Bool, QueueView.ToolBar); \
  685. ); \
  686. BLOCK("Interface\\Updates", CANCREATE, \
  687. KEY(Integer, FUpdates.Period); \
  688. KEY(DateTime, FUpdates.LastCheck); \
  689. KEY(Integer, FUpdates.HaveResults); \
  690. KEY(Integer, FUpdates.ShownResults); \
  691. KEY(Integer, FUpdates.ConnectionType); \
  692. KEY(String, FUpdates.ProxyHost); \
  693. KEY(Integer, FUpdates.ProxyPort); \
  694. KEY(Integer, FUpdates.Results.ForVersion); \
  695. KEY(Integer, FUpdates.Results.Version); \
  696. KEY(String, FUpdates.Results.Message); \
  697. KEY(Integer, FUpdates.Results.Critical); \
  698. KEY(String, FUpdates.Results.Release); \
  699. KEY(Bool, FUpdates.Results.Disabled); \
  700. KEY(String, FUpdates.Results.Url); \
  701. KEY(String, FUpdates.Results.UrlButton); \
  702. ); \
  703. BLOCK("Interface\\Explorer", CANCREATE, \
  704. KEY(String, ScpExplorer.ToolbarsLayout); \
  705. KEY(String, ScpExplorer.DirViewParams); \
  706. KEY(String, ScpExplorer.LastLocalTargetDirectory); \
  707. KEY(Bool, ScpExplorer.StatusBar); \
  708. KEY(String, ScpExplorer.WindowParams); \
  709. KEY(Integer, ScpExplorer.ViewStyle); \
  710. KEY(Bool, ScpExplorer.ShowFullAddress); \
  711. KEY(Bool, ScpExplorer.DriveView); \
  712. KEY(Integer, ScpExplorer.DriveViewWidth); \
  713. ); \
  714. BLOCK("Interface\\Commander", CANCREATE, \
  715. KEY(String, ScpCommander.ToolbarsLayout); \
  716. KEY(Integer, ScpCommander.CurrentPanel); \
  717. KEY(Float, ScpCommander.LocalPanelWidth); \
  718. KEY(Bool, ScpCommander.SwappedPanels); \
  719. KEY(Bool, ScpCommander.StatusBar); \
  720. KEY(String, ScpCommander.WindowParams); \
  721. KEYEX(Integer, ScpCommander.NortonLikeMode, ExplorerStyleSelection); \
  722. KEY(Bool, ScpCommander.PreserveLocalDirectory); \
  723. KEY(Bool, ScpCommander.CompareByTime); \
  724. KEY(Bool, ScpCommander.CompareBySize); \
  725. KEY(Bool, ScpCommander.FullRowSelect); \
  726. ); \
  727. BLOCK("Interface\\Commander\\LocalPanel", CANCREATE, \
  728. KEY(String, ScpCommander.LocalPanel.DirViewParams); \
  729. KEY(Bool, ScpCommander.LocalPanel.StatusBar); \
  730. KEY(Bool, ScpCommander.LocalPanel.DriveView); \
  731. KEY(Integer, ScpCommander.LocalPanel.DriveViewHeight); \
  732. ); \
  733. BLOCK("Interface\\Commander\\RemotePanel", CANCREATE, \
  734. KEY(String, ScpCommander.RemotePanel.DirViewParams); \
  735. KEY(Bool, ScpCommander.RemotePanel.StatusBar); \
  736. KEY(Bool, ScpCommander.RemotePanel.DriveView); \
  737. KEY(Integer, ScpCommander.RemotePanel.DriveViewHeight); \
  738. ); \
  739. BLOCK("Logging", CANCREATE, \
  740. KEY(Bool, LogWindowOnStartup); \
  741. KEY(String, LogWindowParams); \
  742. );
  743. //---------------------------------------------------------------------------
  744. void __fastcall TWinConfiguration::SaveData(THierarchicalStorage * Storage, bool All)
  745. {
  746. TCustomWinConfiguration::SaveData(Storage, All);
  747. // duplicated from core\configuration.cpp
  748. #define KEYEX(TYPE, VAR, NAME) Storage->Write ## TYPE(LASTELEM(AnsiString(#NAME)), VAR)
  749. REGCONFIG(true);
  750. #undef KEYEX
  751. if (Storage->OpenSubKey("Bookmarks", true))
  752. {
  753. FBookmarks->Save(Storage, All);
  754. Storage->CloseSubKey();
  755. }
  756. if ((All && !FCustomCommandsDefaults) || FCustomCommandsModified)
  757. {
  758. if (Storage->OpenSubKey("CustomCommands", true))
  759. {
  760. Storage->WriteValues(FCustomCommands, true);
  761. Storage->CloseSubKey();
  762. }
  763. if (Storage->OpenSubKey("CustomCommandsParams", true))
  764. {
  765. Storage->ClearValues();
  766. for (int Index = 0; Index < FCustomCommands->Count; Index++)
  767. {
  768. Storage->WriteInteger(FCustomCommands->Names[Index],
  769. FCustomCommands->Params[FCustomCommands->Names[Index]]);
  770. }
  771. Storage->CloseSubKey();
  772. }
  773. }
  774. if ((All || FEditorList->Modified) &&
  775. Storage->OpenSubKey("Interface\\Editor", true))
  776. try
  777. {
  778. FEditorList->Save(Storage);
  779. }
  780. __finally
  781. {
  782. Storage->CloseSubKey();
  783. }
  784. }
  785. //---------------------------------------------------------------------------
  786. void __fastcall TWinConfiguration::Load()
  787. {
  788. FLegacyEditor = new TEditorPreferences();
  789. try
  790. {
  791. FLegacyEditor->LegacyDefaults();
  792. TCustomWinConfiguration::Load();
  793. int EditorCount = FEditorList->Count;
  794. if (EditorCount == 0)
  795. {
  796. TEditorPreferences * AlternativeEditor = NULL;
  797. try
  798. {
  799. if (FLegacyEditor->Data.Editor == edInternal)
  800. {
  801. if (!FLegacyEditor->Data.ExternalEditor.IsEmpty())
  802. {
  803. AlternativeEditor = new TEditorPreferences(*FLegacyEditor);
  804. AlternativeEditor->Data.Editor = edExternal;
  805. FLegacyEditor->Data.ExternalEditor = "";
  806. }
  807. }
  808. else
  809. {
  810. if (FLegacyEditor->Data.ExternalEditor.IsEmpty())
  811. {
  812. FLegacyEditor->Data.Editor = edInternal;
  813. }
  814. else
  815. {
  816. AlternativeEditor = new TEditorPreferences(*FLegacyEditor);
  817. AlternativeEditor->Data.Editor = edInternal;
  818. }
  819. }
  820. }
  821. catch(...)
  822. {
  823. delete AlternativeEditor;
  824. throw;
  825. }
  826. FEditorList->Add(FLegacyEditor);
  827. FLegacyEditor = NULL;
  828. if (AlternativeEditor != NULL)
  829. {
  830. FEditorList->Add(AlternativeEditor);
  831. }
  832. }
  833. }
  834. __finally
  835. {
  836. delete FLegacyEditor;
  837. FLegacyEditor = NULL;
  838. }
  839. if (FUpdates.ConnectionType == -1)
  840. {
  841. FUpdates.ConnectionType = (FUpdates.ProxyHost.IsEmpty() ? ctAuto : ctProxy);
  842. }
  843. }
  844. //---------------------------------------------------------------------------
  845. void __fastcall TWinConfiguration::LoadData(THierarchicalStorage * Storage)
  846. {
  847. TCustomWinConfiguration::LoadData(Storage);
  848. // duplicated from core\configuration.cpp
  849. #define KEYEX(TYPE, VAR, NAME) VAR = Storage->Read ## TYPE(LASTELEM(AnsiString(#NAME)), VAR)
  850. #pragma warn -eas
  851. REGCONFIG(false);
  852. #pragma warn +eas
  853. #undef KEYEX
  854. if (Storage->OpenSubKey("Bookmarks", false))
  855. {
  856. FBookmarks->Load(Storage);
  857. Storage->CloseSubKey();
  858. }
  859. if (Storage->OpenSubKey("CustomCommands", false))
  860. {
  861. FCustomCommands->Clear();
  862. Storage->ReadValues(FCustomCommands, true);
  863. Storage->CloseSubKey();
  864. if (Storage->OpenSubKey("CustomCommandsParams", false))
  865. {
  866. for (int Index = 0; Index < FCustomCommands->Count; Index++)
  867. {
  868. AnsiString Name = FCustomCommands->Names[Index];
  869. FCustomCommands->Params[Name] =
  870. Storage->ReadInteger(Name, FCustomCommands->Params[Name]);
  871. }
  872. Storage->CloseSubKey();
  873. }
  874. FCustomCommandsDefaults = false;
  875. }
  876. else if (FCustomCommandsModified)
  877. {
  878. FCustomCommands->Clear();
  879. FCustomCommandsDefaults = false;
  880. }
  881. FCustomCommandsModified = false;
  882. if (Storage->OpenSubKey("Interface\\Editor", false))
  883. try
  884. {
  885. FEditorList->Clear();
  886. FEditorList->Load(Storage);
  887. }
  888. __finally
  889. {
  890. Storage->CloseSubKey();
  891. }
  892. // load legacy editor configuration
  893. assert(FLegacyEditor != NULL);
  894. if (Storage->OpenSubKey("Interface\\Editor", false))
  895. {
  896. try
  897. {
  898. FLegacyEditor->Load(Storage, true);
  899. }
  900. __finally
  901. {
  902. Storage->CloseSubKey();
  903. }
  904. }
  905. }
  906. //---------------------------------------------------------------------------
  907. void __fastcall TWinConfiguration::LoadAdmin(THierarchicalStorage * Storage)
  908. {
  909. TConfiguration::LoadAdmin(Storage);
  910. FDisableOpenEdit = Storage->ReadBool("DisableOpenEdit", FDisableOpenEdit);
  911. }
  912. //---------------------------------------------------------------------------
  913. void __fastcall TWinConfiguration::ClearTemporaryLoginData()
  914. {
  915. if (!FTemporaryKeyFile.IsEmpty())
  916. {
  917. DeleteFile(FTemporaryKeyFile);
  918. FTemporaryKeyFile = "";
  919. }
  920. }
  921. //---------------------------------------------------------------------------
  922. bool __fastcall TWinConfiguration::GetDDExtInstalled()
  923. {
  924. if (FDDExtInstalled < 0)
  925. {
  926. if (IsWin64())
  927. {
  928. // temporarily consider dragext always present on 64-bit system
  929. FDDExtInstalled = 1;
  930. }
  931. else
  932. {
  933. void * DragExtRef;
  934. bool Result;
  935. Result = (CoCreateInstance(CLSID_ShellExtension, NULL,
  936. CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER, IID_IUnknown,
  937. &DragExtRef) == S_OK);
  938. FDDExtInstalled = (Result ? 1 : 0);
  939. if (Result)
  940. {
  941. reinterpret_cast<IUnknown *>(DragExtRef)->Release();
  942. CoFreeUnusedLibraries();
  943. }
  944. }
  945. }
  946. return (FDDExtInstalled > 0);
  947. }
  948. //---------------------------------------------------------------------------
  949. void __fastcall TWinConfiguration::SetLogWindowOnStartup(bool value)
  950. {
  951. SET_CONFIG_PROPERTY(LogWindowOnStartup);
  952. }
  953. //---------------------------------------------------------------------------
  954. void __fastcall TWinConfiguration::SetLogWindowParams(AnsiString value)
  955. {
  956. SET_CONFIG_PROPERTY(LogWindowParams);
  957. }
  958. //---------------------------------------------------------------------------
  959. void __fastcall TWinConfiguration::SetDDAllowMove(bool value)
  960. {
  961. SET_CONFIG_PROPERTY(DDAllowMove);
  962. }
  963. //---------------------------------------------------------------------------
  964. void __fastcall TWinConfiguration::SetDDAllowMoveInit(bool value)
  965. {
  966. SET_CONFIG_PROPERTY(DDAllowMoveInit);
  967. }
  968. //---------------------------------------------------------------------------
  969. void __fastcall TWinConfiguration::SetDDTransferConfirmation(bool value)
  970. {
  971. SET_CONFIG_PROPERTY(DDTransferConfirmation);
  972. }
  973. //---------------------------------------------------------------------------
  974. void __fastcall TWinConfiguration::SetDDTemporaryDirectory(AnsiString value)
  975. {
  976. SET_CONFIG_PROPERTY(DDTemporaryDirectory);
  977. }
  978. //---------------------------------------------------------------------------
  979. void __fastcall TWinConfiguration::SetDDExtEnabled(bool value)
  980. {
  981. SET_CONFIG_PROPERTY(DDExtEnabled);
  982. }
  983. //---------------------------------------------------------------------------
  984. void __fastcall TWinConfiguration::SetDDExtTimeout(int value)
  985. {
  986. SET_CONFIG_PROPERTY(DDExtTimeout);
  987. }
  988. //---------------------------------------------------------------------------
  989. void __fastcall TWinConfiguration::SetDDWarnLackOfTempSpace(bool value)
  990. {
  991. SET_CONFIG_PROPERTY(DDWarnLackOfTempSpace);
  992. }
  993. //---------------------------------------------------------------------------
  994. void __fastcall TWinConfiguration::SetDDWarnLackOfTempSpaceRatio(double value)
  995. {
  996. SET_CONFIG_PROPERTY(DDWarnLackOfTempSpaceRatio);
  997. }
  998. //---------------------------------------------------------------------------
  999. void __fastcall TWinConfiguration::SetScpExplorer(TScpExplorerConfiguration value)
  1000. {
  1001. SET_CONFIG_PROPERTY(ScpExplorer);
  1002. }
  1003. //---------------------------------------------------------------------------
  1004. void __fastcall TWinConfiguration::SetScpCommander(TScpCommanderConfiguration value)
  1005. {
  1006. SET_CONFIG_PROPERTY(ScpCommander);
  1007. }
  1008. //---------------------------------------------------------------------------
  1009. void __fastcall TWinConfiguration::SetEditor(TEditorConfiguration value)
  1010. {
  1011. SET_CONFIG_PROPERTY(Editor);
  1012. }
  1013. //---------------------------------------------------------------------------
  1014. void __fastcall TWinConfiguration::SetQueueView(TQueueViewConfiguration value)
  1015. {
  1016. SET_CONFIG_PROPERTY(QueueView);
  1017. }
  1018. //---------------------------------------------------------------------------
  1019. TUpdatesConfiguration __fastcall TWinConfiguration::GetUpdates()
  1020. {
  1021. TUpdatesConfiguration Result;
  1022. {
  1023. TGuard Guard(FCriticalSection);
  1024. Result = FUpdates;
  1025. }
  1026. return Result;
  1027. }
  1028. //---------------------------------------------------------------------------
  1029. void __fastcall TWinConfiguration::SetUpdates(TUpdatesConfiguration value)
  1030. {
  1031. TGuard Guard(FCriticalSection);
  1032. // do not use SET_CONFIG_PROPERTY to avoid OnChange handler call (not synchronized)
  1033. FUpdates = value;
  1034. }
  1035. //---------------------------------------------------------------------------
  1036. void __fastcall TWinConfiguration::SetDeleteToRecycleBin(bool value)
  1037. {
  1038. SET_CONFIG_PROPERTY(DeleteToRecycleBin);
  1039. }
  1040. //---------------------------------------------------------------------------
  1041. void __fastcall TWinConfiguration::SetSelectDirectories(bool value)
  1042. {
  1043. SET_CONFIG_PROPERTY(SelectDirectories);
  1044. }
  1045. //---------------------------------------------------------------------------
  1046. void __fastcall TWinConfiguration::SetShowHiddenFiles(bool value)
  1047. {
  1048. SET_CONFIG_PROPERTY(ShowHiddenFiles);
  1049. }
  1050. //---------------------------------------------------------------------------
  1051. void __fastcall TWinConfiguration::SetShowInaccesibleDirectories(bool value)
  1052. {
  1053. SET_CONFIG_PROPERTY(ShowInaccesibleDirectories);
  1054. }
  1055. //---------------------------------------------------------------------------
  1056. void __fastcall TWinConfiguration::SetConfirmTransferring(bool value)
  1057. {
  1058. SET_CONFIG_PROPERTY(ConfirmTransferring);
  1059. }
  1060. //---------------------------------------------------------------------------
  1061. void __fastcall TWinConfiguration::SetConfirmDeleting(bool value)
  1062. {
  1063. SET_CONFIG_PROPERTY(ConfirmDeleting);
  1064. }
  1065. //---------------------------------------------------------------------------
  1066. void __fastcall TWinConfiguration::SetConfirmRecycling(bool value)
  1067. {
  1068. SET_CONFIG_PROPERTY(ConfirmRecycling);
  1069. }
  1070. //---------------------------------------------------------------------------
  1071. void __fastcall TWinConfiguration::SetUseLocationProfiles(bool value)
  1072. {
  1073. SET_CONFIG_PROPERTY(UseLocationProfiles);
  1074. }
  1075. //---------------------------------------------------------------------------
  1076. void __fastcall TWinConfiguration::SetConfirmClosingSession(bool value)
  1077. {
  1078. SET_CONFIG_PROPERTY(ConfirmClosingSession);
  1079. }
  1080. //---------------------------------------------------------------------------
  1081. void __fastcall TWinConfiguration::SetConfirmExitOnCompletion(bool value)
  1082. {
  1083. SET_CONFIG_PROPERTY(ConfirmExitOnCompletion);
  1084. }
  1085. //---------------------------------------------------------------------------
  1086. void __fastcall TWinConfiguration::SetDoubleClickAction(TDoubleClickAction value)
  1087. {
  1088. SET_CONFIG_PROPERTY(DoubleClickAction);
  1089. }
  1090. //---------------------------------------------------------------------------
  1091. void __fastcall TWinConfiguration::SetCopyOnDoubleClickConfirmation(bool value)
  1092. {
  1093. SET_CONFIG_PROPERTY(CopyOnDoubleClickConfirmation);
  1094. }
  1095. //---------------------------------------------------------------------------
  1096. void __fastcall TWinConfiguration::SetDimmHiddenFiles(bool value)
  1097. {
  1098. SET_CONFIG_PROPERTY(DimmHiddenFiles);
  1099. }
  1100. //---------------------------------------------------------------------------
  1101. void __fastcall TWinConfiguration::SetAutoStartSession(AnsiString value)
  1102. {
  1103. SET_CONFIG_PROPERTY(AutoStartSession);
  1104. }
  1105. //---------------------------------------------------------------------------
  1106. void __fastcall TWinConfiguration::SetExpertMode(bool value)
  1107. {
  1108. SET_CONFIG_PROPERTY(ExpertMode);
  1109. }
  1110. //---------------------------------------------------------------------------
  1111. void __fastcall TWinConfiguration::SetDefaultDirIsHome(bool value)
  1112. {
  1113. SET_CONFIG_PROPERTY(DefaultDirIsHome);
  1114. }
  1115. //---------------------------------------------------------------------------
  1116. void __fastcall TWinConfiguration::SetTemporaryDirectoryCleanup(bool value)
  1117. {
  1118. SET_CONFIG_PROPERTY(TemporaryDirectoryCleanup);
  1119. }
  1120. //---------------------------------------------------------------------------
  1121. void __fastcall TWinConfiguration::SetConfirmTemporaryDirectoryCleanup(bool value)
  1122. {
  1123. SET_CONFIG_PROPERTY(ConfirmTemporaryDirectoryCleanup);
  1124. }
  1125. //---------------------------------------------------------------------------
  1126. void __fastcall TWinConfiguration::SetPreservePanelState(bool value)
  1127. {
  1128. SET_CONFIG_PROPERTY(PreservePanelState);
  1129. }
  1130. //---------------------------------------------------------------------------
  1131. void __fastcall TWinConfiguration::SetTheme(AnsiString value)
  1132. {
  1133. SET_CONFIG_PROPERTY_EX(Theme, ConfigureInterface());
  1134. }
  1135. //---------------------------------------------------------------------------
  1136. void __fastcall TWinConfiguration::SetPathInCaption(TPathInCaption value)
  1137. {
  1138. SET_CONFIG_PROPERTY(PathInCaption);
  1139. }
  1140. //---------------------------------------------------------------------------
  1141. void __fastcall TWinConfiguration::SetMinimizeToTray(bool value)
  1142. {
  1143. SET_CONFIG_PROPERTY(MinimizeToTray);
  1144. }
  1145. //---------------------------------------------------------------------------
  1146. void __fastcall TWinConfiguration::SetBalloonNotifications(bool value)
  1147. {
  1148. SET_CONFIG_PROPERTY(BalloonNotifications);
  1149. }
  1150. //---------------------------------------------------------------------------
  1151. void __fastcall TWinConfiguration::SetNotificationsTimeout(unsigned int value)
  1152. {
  1153. SET_CONFIG_PROPERTY(NotificationsTimeout);
  1154. }
  1155. //---------------------------------------------------------------------------
  1156. void __fastcall TWinConfiguration::SetNotificationsStickTime(unsigned int value)
  1157. {
  1158. SET_CONFIG_PROPERTY(NotificationsStickTime);
  1159. }
  1160. //---------------------------------------------------------------------------
  1161. void __fastcall TWinConfiguration::SetCopyParamAutoSelectNotice(bool value)
  1162. {
  1163. SET_CONFIG_PROPERTY(CopyParamAutoSelectNotice);
  1164. }
  1165. //---------------------------------------------------------------------------
  1166. void __fastcall TWinConfiguration::SetSessionToolbarAutoShown(bool value)
  1167. {
  1168. SET_CONFIG_PROPERTY(SessionToolbarAutoShown);
  1169. }
  1170. //---------------------------------------------------------------------------
  1171. void __fastcall TWinConfiguration::SetLockToolbars(bool value)
  1172. {
  1173. SET_CONFIG_PROPERTY(LockToolbars);
  1174. }
  1175. //---------------------------------------------------------------------------
  1176. void __fastcall TWinConfiguration::SetAutoOpenInPutty(bool value)
  1177. {
  1178. SET_CONFIG_PROPERTY(AutoOpenInPutty);
  1179. }
  1180. //---------------------------------------------------------------------------
  1181. void __fastcall TWinConfiguration::SetCustomCommands(TCustomCommands * value)
  1182. {
  1183. assert(FCustomCommands);
  1184. if (!FCustomCommands->Equals(value))
  1185. {
  1186. FCustomCommands->Assign(value);
  1187. FCustomCommandsModified = true;
  1188. FCustomCommandsDefaults = false;
  1189. }
  1190. }
  1191. //---------------------------------------------------------------------------
  1192. void __fastcall TWinConfiguration::SetBookmarks(AnsiString Key,
  1193. TBookmarkList * value)
  1194. {
  1195. FBookmarks->Bookmarks[Key] = value;
  1196. Changed();
  1197. }
  1198. //---------------------------------------------------------------------------
  1199. TBookmarkList * __fastcall TWinConfiguration::GetBookmarks(AnsiString Key)
  1200. {
  1201. return FBookmarks->Bookmarks[Key];
  1202. }
  1203. //---------------------------------------------------------------------------
  1204. AnsiString __fastcall TWinConfiguration::GetDefaultKeyFile()
  1205. {
  1206. return (!FDefaultKeyFile.IsEmpty() ? FDefaultKeyFile : FTemporaryKeyFile);
  1207. }
  1208. //---------------------------------------------------------------------------
  1209. void __fastcall TWinConfiguration::SetLastMonitor(int value)
  1210. {
  1211. ::SetLastMonitor(value);
  1212. }
  1213. //---------------------------------------------------------------------------
  1214. int __fastcall TWinConfiguration::GetLastMonitor()
  1215. {
  1216. return ::GetLastMonitor();
  1217. }
  1218. //---------------------------------------------------------------------------
  1219. AnsiString __fastcall TWinConfiguration::TemporaryDir(bool Mask)
  1220. {
  1221. return UniqTempDir(ExpandFileName(ExpandEnvironmentVariables(DDTemporaryDirectory)),
  1222. "scp", Mask);
  1223. }
  1224. //---------------------------------------------------------------------------
  1225. TStrings * __fastcall TWinConfiguration::FindTemporaryFolders()
  1226. {
  1227. TStrings * Result = new TStringList();
  1228. try
  1229. {
  1230. TSearchRec SRec;
  1231. AnsiString Mask = TemporaryDir(true);
  1232. AnsiString Directory = ExtractFilePath(Mask);
  1233. if (FindFirst(Mask, faDirectory, SRec) == 0)
  1234. {
  1235. do
  1236. {
  1237. if (FLAGSET(SRec.Attr, faDirectory))
  1238. {
  1239. Result->Add(Directory + SRec.Name);
  1240. }
  1241. }
  1242. while (FindNext(SRec) == 0);
  1243. }
  1244. if (Result->Count == 0)
  1245. {
  1246. delete Result;
  1247. Result = NULL;
  1248. }
  1249. }
  1250. catch(...)
  1251. {
  1252. delete Result;
  1253. throw;
  1254. }
  1255. return Result;
  1256. }
  1257. //---------------------------------------------------------------------------
  1258. void __fastcall TWinConfiguration::CleanupTemporaryFolders(TStrings * Folders)
  1259. {
  1260. AnsiString ErrorList;
  1261. TStrings * F;
  1262. if (Folders == NULL)
  1263. {
  1264. F = FindTemporaryFolders();
  1265. }
  1266. else
  1267. {
  1268. F = Folders;
  1269. }
  1270. if (F != NULL)
  1271. {
  1272. try
  1273. {
  1274. for (int i = 0; i < F->Count; i++)
  1275. {
  1276. if (!DeleteDirectory(F->Strings[i]))
  1277. {
  1278. if (!ErrorList.IsEmpty())
  1279. {
  1280. ErrorList += "\n";
  1281. }
  1282. ErrorList += F->Strings[i];
  1283. }
  1284. }
  1285. }
  1286. __finally
  1287. {
  1288. if (Folders == NULL)
  1289. {
  1290. delete F;
  1291. }
  1292. }
  1293. if (!ErrorList.IsEmpty())
  1294. {
  1295. throw ExtException(LoadStr(CLEANUP_TEMP_ERROR), ErrorList);
  1296. }
  1297. }
  1298. }
  1299. //---------------------------------------------------------------------------
  1300. //---------------------------------------------------------------------------
  1301. #pragma warn -inl
  1302. //---------------------------------------------------------------------------
  1303. class TAsInheritedReader : public TReader
  1304. {
  1305. public:
  1306. __fastcall TAsInheritedReader(TStream * Stream, int BufSize) :
  1307. TReader(Stream, BufSize)
  1308. {
  1309. OnAncestorNotFound = AncestorNotFound;
  1310. }
  1311. virtual void __fastcall ReadPrefix(TFilerFlags & Flags, int & AChildPos)
  1312. {
  1313. TReader::ReadPrefix(Flags, AChildPos);
  1314. Flags << ffInherited;
  1315. }
  1316. void __fastcall AncestorNotFound(TReader * Reader,
  1317. const AnsiString ComponentName, TMetaClass * ComponentClass,
  1318. TComponent *& Component)
  1319. {
  1320. assert(!Component);
  1321. if (ComponentName.IsEmpty())
  1322. {
  1323. for (int Index = 0; Index < LookupRoot->ComponentCount; Index++)
  1324. {
  1325. Component = LookupRoot->Components[Index];
  1326. if (Component->Name.IsEmpty())
  1327. {
  1328. return;
  1329. }
  1330. }
  1331. Component = NULL;
  1332. }
  1333. }
  1334. };
  1335. //---------------------------------------------------------------------------
  1336. #pragma warn .inl
  1337. //---------------------------------------------------------------------------
  1338. bool __fastcall TWinConfiguration::InternalReloadComponentRes(const AnsiString ResName,
  1339. HANDLE HInst, TComponent * Instance)
  1340. {
  1341. HANDLE HRsrc;
  1342. bool Result;
  1343. if (!HInst)
  1344. {
  1345. HInst = HInstance;
  1346. }
  1347. HRsrc = FindResource(HInst, ResName.c_str(), RT_RCDATA);
  1348. Result = (HRsrc != 0);
  1349. if (Result)
  1350. {
  1351. TResourceStream * ResStream = new TResourceStream(
  1352. reinterpret_cast<int>(HInst), ResName, RT_RCDATA);
  1353. try
  1354. {
  1355. TReader * Reader;
  1356. Reader = new TAsInheritedReader(ResStream, 4096);
  1357. try
  1358. {
  1359. /*Instance =*/ Reader->ReadRootComponent(Instance);
  1360. }
  1361. __finally
  1362. {
  1363. delete Reader;
  1364. }
  1365. }
  1366. __finally
  1367. {
  1368. delete ResStream;
  1369. }
  1370. }
  1371. return Result;
  1372. }
  1373. //---------------------------------------------------------------------------
  1374. bool __fastcall TWinConfiguration::InitComponent(TComponent * Instance,
  1375. TClass RootAncestor, TClass ClassType)
  1376. {
  1377. bool Result = false;
  1378. if ((ClassType != __classid(TComponent)) && (ClassType != RootAncestor))
  1379. {
  1380. if (InitComponent(Instance, RootAncestor, ClassType->ClassParent()))
  1381. {
  1382. Result = true;
  1383. }
  1384. if (InternalReloadComponentRes(ClassType->ClassName(),
  1385. reinterpret_cast<HANDLE>(FindResourceHInstance(FindClassHInstance(ClassType))),
  1386. Instance))
  1387. {
  1388. Result = true;
  1389. }
  1390. }
  1391. return Result;
  1392. }
  1393. //---------------------------------------------------------------------------
  1394. LCID __fastcall TWinConfiguration::GetLocale()
  1395. {
  1396. if (!FLocale)
  1397. {
  1398. AnsiString ResourceModule = ::GetResourceModule(ModuleFileName().c_str());
  1399. if (!ResourceModule.IsEmpty())
  1400. {
  1401. AnsiString ResourceExt = ExtractFileExt(ResourceModule).UpperCase();
  1402. ResourceExt.Delete(1, 1);
  1403. TLanguages * Langs = LanguagesDEPF();
  1404. int Index, Count;
  1405. Count = Langs->Count;
  1406. Index = 0;
  1407. while ((Index < Count) && !FLocale)
  1408. {
  1409. if (Langs->Ext[Index] == ResourceExt)
  1410. {
  1411. FLocale = Langs->LocaleID[Index];
  1412. }
  1413. else if (Langs->Ext[Index].SubString(1, 2) == ResourceExt)
  1414. {
  1415. FLocale = MAKELANGID(PRIMARYLANGID(Langs->LocaleID[Index]),
  1416. SUBLANG_DEFAULT);
  1417. }
  1418. Index++;
  1419. }
  1420. }
  1421. }
  1422. return TCustomWinConfiguration::GetLocale();
  1423. }
  1424. //---------------------------------------------------------------------------
  1425. HINSTANCE __fastcall TWinConfiguration::LoadNewResourceModule(LCID ALocale,
  1426. AnsiString * FileName)
  1427. {
  1428. AnsiString FileNameStorage;
  1429. if (FileName == NULL)
  1430. {
  1431. FileName = &FileNameStorage;
  1432. }
  1433. HINSTANCE Instance = TCustomWinConfiguration::LoadNewResourceModule(ALocale, FileName);
  1434. if (Instance != NULL)
  1435. {
  1436. try
  1437. {
  1438. CheckTranslationVersion(*FileName, false);
  1439. }
  1440. catch(...)
  1441. {
  1442. FreeResourceModule(Instance);
  1443. throw;
  1444. }
  1445. }
  1446. return Instance;
  1447. }
  1448. //---------------------------------------------------------------------------
  1449. void __fastcall TWinConfiguration::SetResourceModule(HINSTANCE Instance)
  1450. {
  1451. TCustomWinConfiguration::SetResourceModule(Instance);
  1452. Busy(true);
  1453. try
  1454. {
  1455. int Count;
  1456. AnsiString OrigName;
  1457. int OrigLeft;
  1458. int OrigTop;
  1459. TForm * Form;
  1460. Count = Screen->FormCount;
  1461. for (int Index = 0; Index < Count; Index++)
  1462. {
  1463. Form = Screen->Forms[Index];
  1464. SendMessage(Form->Handle, WM_LOCALE_CHANGE, 0, 1);
  1465. }
  1466. ConfigureInterface();
  1467. for (int Index = 0; Index < Count; Index++)
  1468. {
  1469. Form = Screen->Forms[Index];
  1470. TComponent * Component;
  1471. for (int Index = 0; Index < Form->ComponentCount; Index++)
  1472. {
  1473. Component = Form->Components[Index];
  1474. if (dynamic_cast<TFrame*>(Component))
  1475. {
  1476. OrigName = Component->Name;
  1477. InitComponent(Component, __classid(TFrame), Component->ClassType());
  1478. Component->Name = OrigName;
  1479. }
  1480. }
  1481. OrigLeft = Form->Left;
  1482. OrigTop = Form->Top;
  1483. OrigName = Form->Name;
  1484. InitComponent(Form, __classid(TForm), Form->ClassType());
  1485. Form->Name = OrigName;
  1486. Form->Position = poDesigned;
  1487. Form->Left = OrigLeft;
  1488. Form->Top = OrigTop;
  1489. SendMessage(Form->Handle, WM_LOCALE_CHANGE, 1, 1);
  1490. }
  1491. TDataModule * DataModule;
  1492. Count = Screen->DataModuleCount;
  1493. for (int Index = 0; Index < Count; Index++)
  1494. {
  1495. DataModule = Screen->DataModules[Index];
  1496. OrigName = DataModule->Name;
  1497. InitComponent(DataModule, __classid(TDataModule), DataModule->ClassType());
  1498. DataModule->Name = OrigName;
  1499. }
  1500. }
  1501. __finally
  1502. {
  1503. Busy(false);
  1504. }
  1505. }
  1506. //---------------------------------------------------------------------------
  1507. void __fastcall TWinConfiguration::CheckTranslationVersion(const AnsiString FileName,
  1508. bool InternalLocaleOnError)
  1509. {
  1510. AnsiString TranslationProductVersion = GetFileProductVersion(FileName);
  1511. AnsiString TranslationProductName = GetFileProductName(FileName);
  1512. if ((ProductName != TranslationProductName) ||
  1513. (ProductVersion != TranslationProductVersion))
  1514. {
  1515. if (InternalLocaleOnError)
  1516. {
  1517. LocaleSafe = InternalLocale();
  1518. }
  1519. if (TranslationProductName.IsEmpty() || TranslationProductVersion.IsEmpty())
  1520. {
  1521. throw Exception(FMTLOAD(UNKNOWN_TRANSLATION, (FileName)));
  1522. }
  1523. else
  1524. {
  1525. throw Exception(FMTLOAD(INCOMPATIBLE_TRANSLATION,
  1526. (FileName, TranslationProductName, TranslationProductVersion)));
  1527. }
  1528. }
  1529. }
  1530. //---------------------------------------------------------------------------
  1531. void __fastcall TWinConfiguration::CheckDefaultTranslation()
  1532. {
  1533. if (!FInvalidDefaultTranslationMessage.IsEmpty())
  1534. {
  1535. MoreMessageDialog(FMTLOAD(INVALID_DEFAULT_TRANSLATION,
  1536. (FInvalidDefaultTranslationMessage)), NULL, qtWarning, qaOK, HELP_NONE);
  1537. }
  1538. }
  1539. //---------------------------------------------------------------------------
  1540. const TEditorPreferences * __fastcall TWinConfiguration::DefaultEditorForFile(
  1541. const AnsiString FileName, bool Local, const TFileMasks::TParams & MaskParams)
  1542. {
  1543. return FEditorList->Find(FileName, Local, MaskParams);
  1544. }
  1545. //---------------------------------------------------------------------------
  1546. const TEditorList * __fastcall TWinConfiguration::GetEditorList()
  1547. {
  1548. return FEditorList;
  1549. }
  1550. //---------------------------------------------------------------------------
  1551. void __fastcall TWinConfiguration::SetEditorList(const TEditorList * value)
  1552. {
  1553. if (!(*FEditorList == *value))
  1554. {
  1555. *FEditorList = *value;
  1556. Changed();
  1557. }
  1558. }
  1559. //---------------------------------------------------------------------------
  1560. //---------------------------------------------------------------------------
  1561. int __fastcall TCustomCommands::GetParam(const AnsiString & Name)
  1562. {
  1563. int Index = IndexOfName(Name);
  1564. if (Index >= 0)
  1565. {
  1566. return int(Objects[Index]);
  1567. }
  1568. else
  1569. {
  1570. return 0;
  1571. }
  1572. }
  1573. //---------------------------------------------------------------------------
  1574. void __fastcall TCustomCommands::SetParam(const AnsiString & Name, int value)
  1575. {
  1576. int Index = IndexOfName(Name);
  1577. if (Index >= 0)
  1578. {
  1579. Objects[Index] = (TObject *)value;
  1580. }
  1581. else
  1582. {
  1583. Values[Name] = "";
  1584. Index = IndexOfName(Name);
  1585. assert(Index >= 0);
  1586. Objects[Index] = (TObject *)value;
  1587. }
  1588. }
  1589. //---------------------------------------------------------------------------
  1590. bool __fastcall TCustomCommands::Equals(TCustomCommands * Commands)
  1591. {
  1592. bool Result = TStringList::Equals(Commands);
  1593. if (Result)
  1594. {
  1595. int Index = 0;
  1596. while ((Index < Count) && Result)
  1597. {
  1598. if (Objects[Index] != Commands->Objects[Index])
  1599. {
  1600. Result = false;
  1601. }
  1602. Index++;
  1603. }
  1604. }
  1605. return Result;
  1606. }