Authenticate.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include <Common.h>
  5. #include "Authenticate.h"
  6. #include <VCLCommon.h>
  7. #include <TextsWin.h>
  8. #include <Terminal.h>
  9. #include <CoreMain.h>
  10. #include <PasTools.hpp>
  11. #include <CustomWinConfiguration.h>
  12. //---------------------------------------------------------------------------
  13. #pragma package(smart_init)
  14. #pragma link "PasswordEdit"
  15. #ifndef NO_RESOURCES
  16. #pragma resource "*.dfm"
  17. #endif
  18. //---------------------------------------------------------------------------
  19. __fastcall TAuthenticateForm::TAuthenticateForm(TComponent * Owner)
  20. : TForm(Owner), FSessionData(NULL), FTerminal(NULL)
  21. {
  22. }
  23. //---------------------------------------------------------------------------
  24. void __fastcall TAuthenticateForm::Init(TTerminal * Terminal)
  25. {
  26. FTerminal = Terminal;
  27. FSessionData = Terminal->SessionData;
  28. UseSystemSettings(this);
  29. FShowAsModalStorage = NULL;
  30. FFocusControl = NULL;
  31. UseDesktopFont(LogView);
  32. FAnimationPainted = false;
  33. FShowNoActivate = false;
  34. FPromptParent = InstructionsLabel->Parent;
  35. FPromptLeft = InstructionsLabel->Left;
  36. FPromptTop = InstructionsLabel->Top;
  37. FPromptRight = FPromptParent->ClientWidth - InstructionsLabel->Width - FPromptLeft;
  38. FPromptEditGap = PromptEdit1->Top - PromptLabel1->Top - PromptLabel1->Height;
  39. FPromptsGap = PromptLabel2->Top - PromptEdit1->Top - PromptEdit1->Height;
  40. ClientHeight = ScaleByTextHeight(this, 270);
  41. FHorizontalLogPadding = ScaleByTextHeight(this, 4);
  42. FVerticalLogPadding = ScaleByTextHeight(this, 3);
  43. FLogTextFormat << tfNoPrefix << tfWordBreak << tfVerticalCenter;
  44. ClearLog();
  45. }
  46. //---------------------------------------------------------------------------
  47. __fastcall TAuthenticateForm::~TAuthenticateForm()
  48. {
  49. if (ReleaseAsModal(this, FShowAsModalStorage))
  50. {
  51. UnhookFormActivation(this);
  52. }
  53. }
  54. //---------------------------------------------------------------------------
  55. void __fastcall TAuthenticateForm::ShowAsModal()
  56. {
  57. if (IsApplicationMinimized())
  58. {
  59. FShowNoActivate = true;
  60. }
  61. // Do not call BringToFront when minimized, so that we do not have to use the same hack as in TMessageForm::SetZOrder
  62. ::ShowAsModal(this, FShowAsModalStorage, !FShowNoActivate);
  63. HookFormActivation(this);
  64. }
  65. //---------------------------------------------------------------------------
  66. void __fastcall TAuthenticateForm::CMShowingChanged(TMessage & Message)
  67. {
  68. if (Showing && FShowNoActivate)
  69. {
  70. ShowFormNoActivate(this);
  71. }
  72. else
  73. {
  74. TForm::Dispatch(&Message);
  75. }
  76. }
  77. //---------------------------------------------------------------------------
  78. void __fastcall TAuthenticateForm::WMNCCreate(TWMNCCreate & Message)
  79. {
  80. // bypass TForm::WMNCCreate to prevent disabling "resize"
  81. // (which is done for bsDialog, see comments in CreateParams)
  82. DefaultHandler(&Message);
  83. }
  84. //---------------------------------------------------------------------------
  85. void __fastcall TAuthenticateForm::DoCancel()
  86. {
  87. if (FOnCancel != NULL)
  88. {
  89. FOnCancel(this);
  90. }
  91. }
  92. //---------------------------------------------------------------------------
  93. void __fastcall TAuthenticateForm::Dispatch(void * AMessage)
  94. {
  95. TMessage & Message = *reinterpret_cast<TMessage *>(AMessage);
  96. if (Message.Msg == WM_NCCREATE)
  97. {
  98. WMNCCreate(*reinterpret_cast<TWMNCCreate *>(AMessage));
  99. }
  100. else if (Message.Msg == WM_CLOSE)
  101. {
  102. DoCancel();
  103. TForm::Dispatch(AMessage);
  104. }
  105. else if (Message.Msg == WM_MANAGES_CAPTION)
  106. {
  107. // caption managed in TAuthenticateForm::AdjustControls()
  108. Message.Result = 1;
  109. }
  110. else if (Message.Msg == CM_SHOWINGCHANGED)
  111. {
  112. CMShowingChanged(Message);
  113. }
  114. else
  115. {
  116. TForm::Dispatch(AMessage);
  117. }
  118. }
  119. //---------------------------------------------------------------------------
  120. void __fastcall TAuthenticateForm::CreateParams(TCreateParams & Params)
  121. {
  122. TForm::CreateParams(Params);
  123. // Allow resizing of the window, even if this is bsDialog.
  124. // This makes it more close to bsSizeable, but bsSizeable cannot for some
  125. // reason receive focus, if window is shown atop non-main window
  126. // (like editor)
  127. Params.Style = Params.Style | WS_THICKFRAME;
  128. }
  129. //---------------------------------------------------------------------------
  130. void __fastcall TAuthenticateForm::FormShow(TObject * /*Sender*/)
  131. {
  132. AdjustControls();
  133. if (FFocusControl != NULL)
  134. {
  135. ActiveControl = FFocusControl;
  136. }
  137. UnicodeString AnimationName = FSessionData->IsSecure() ? L"ConnectingSecure" : L"ConnectingInsecure";
  138. FFrameAnimation.Init(AnimationPaintBox, AnimationName);
  139. FFrameAnimation.Start();
  140. }
  141. //---------------------------------------------------------------------------
  142. void __fastcall TAuthenticateForm::ClearLog()
  143. {
  144. // TListItems::Clear() does nothing without allocated handle
  145. LogView->HandleNeeded();
  146. LogView->Items->Clear();
  147. }
  148. //---------------------------------------------------------------------------
  149. void __fastcall TAuthenticateForm::Log(const UnicodeString Message)
  150. {
  151. // HACK
  152. // The first call to Repaint from TFrameAnimation happens
  153. // even before the form is showing. After it is shown it takes sometime too long
  154. // before the animation is painted, so that the form is closed before the first frame even appers
  155. if (!FAnimationPainted && Showing)
  156. {
  157. AnimationPaintBox->Repaint();
  158. FAnimationPainted = true;
  159. }
  160. int Index = LogView->Items->Add(Message);
  161. MakeLogItemVisible(Index);
  162. LogView->Repaint();
  163. }
  164. //---------------------------------------------------------------------------
  165. void __fastcall TAuthenticateForm::MakeLogItemVisible(int Index)
  166. {
  167. if (Index < LogView->TopIndex)
  168. {
  169. LogView->TopIndex = Index;
  170. }
  171. else
  172. {
  173. int TotalHeight = 0;
  174. int Index2 = Index;
  175. while ((Index2 >= 0) && TotalHeight < LogView->ClientHeight)
  176. {
  177. TotalHeight += LogItemHeight(Index2);
  178. Index2--;
  179. }
  180. // Index2 is the last item above the first fully visible,
  181. // were the Index on the very bottom.
  182. if (LogView->TopIndex <= Index2 + 1)
  183. {
  184. LogView->TopIndex = Index2 + 2;
  185. }
  186. }
  187. }
  188. //---------------------------------------------------------------------------
  189. void __fastcall TAuthenticateForm::AdjustControls()
  190. {
  191. UnicodeString ACaption;
  192. if (FStatus.IsEmpty())
  193. {
  194. ACaption = FSessionData->SessionName;
  195. }
  196. else
  197. {
  198. ACaption = FORMAT(L"%s - %s", (FStatus, FSessionData->SessionName));
  199. }
  200. Caption = FormatFormCaption(this, ACaption);
  201. }
  202. //---------------------------------------------------------------------------
  203. TLabel * __fastcall TAuthenticateForm::GenerateLabel(int Current, UnicodeString Caption)
  204. {
  205. TLabel * Result = new TLabel(this);
  206. Result->Parent = FPromptParent;
  207. Result->Anchors = TAnchors() << akLeft << akTop << akRight;
  208. Result->WordWrap = true;
  209. Result->AutoSize = false;
  210. Result->Top = Current;
  211. Result->Left = FPromptLeft;
  212. Result->Caption = Caption;
  213. int Width = FPromptParent->ClientWidth - FPromptLeft - FPromptRight;
  214. Result->Width = Width;
  215. Result->AutoSize = true;
  216. Result->AutoSize = false;
  217. Result->Width = Width;
  218. return Result;
  219. }
  220. //---------------------------------------------------------------------------
  221. TCustomEdit * __fastcall TAuthenticateForm::GenerateEdit(int Current, bool Echo)
  222. {
  223. TCustomEdit * Result = (Echo ? static_cast<TCustomEdit *>(new TEdit(this)) :
  224. static_cast<TCustomEdit *>(new TPasswordEdit(this)));
  225. Result->Parent = FPromptParent;
  226. Result->Anchors = TAnchors() << akLeft << akTop << akRight;
  227. Result->Top = Current;
  228. Result->Left = FPromptLeft;
  229. Result->Width = FPromptParent->ClientWidth - FPromptLeft - FPromptRight;
  230. return Result;
  231. }
  232. //---------------------------------------------------------------------------
  233. TList * __fastcall TAuthenticateForm::GeneratePrompt(UnicodeString Instructions,
  234. TStrings * Prompts)
  235. {
  236. while (FPromptParent->ControlCount > 0)
  237. {
  238. delete FPromptParent->Controls[0];
  239. }
  240. TList * Result = new TList;
  241. int Current = FPromptTop;
  242. if (!Instructions.IsEmpty())
  243. {
  244. TLabel * Label = GenerateLabel(Current, Instructions);
  245. Current += Label->Height + FPromptsGap;
  246. }
  247. for (int Index = 0; Index < Prompts->Count; Index++)
  248. {
  249. if (Index > 0)
  250. {
  251. Current += FPromptEditGap;
  252. }
  253. TLabel * Label = GenerateLabel(Current, Prompts->Strings[Index]);
  254. Current += Label->Height + FPromptEditGap;
  255. bool Echo = FLAGSET(int(Prompts->Objects[Index]), pupEcho);
  256. TCustomEdit * Edit = GenerateEdit(Current, Echo);
  257. Result->Add(Edit);
  258. Label->FocusControl = Edit;
  259. Current += Edit->Height;
  260. }
  261. FPromptParent->ClientHeight = Current;
  262. return Result;
  263. }
  264. //---------------------------------------------------------------------------
  265. bool __fastcall TAuthenticateForm::PromptUser(TPromptKind Kind, UnicodeString Name,
  266. UnicodeString Instructions, TStrings * Prompts, TStrings * Results, bool ForceLog,
  267. bool StoredCredentialsTried)
  268. {
  269. bool Result;
  270. TList * Edits = GeneratePrompt(Instructions, Prompts);
  271. try
  272. {
  273. bool ShowSessionRememberPasswordPanel = false;
  274. bool ShowSavePasswordPanel = false;
  275. TSessionData * Data = NULL;
  276. if (IsPasswordPrompt(Kind, Prompts) && StoredCredentialsTried)
  277. {
  278. Data = StoredSessions->FindSame(FSessionData);
  279. ShowSavePasswordPanel = (Data != NULL) && !Data->Password.IsEmpty();
  280. }
  281. // do not offer to remember password,
  282. // if we are offering to save the password to stored site
  283. if (!ShowSavePasswordPanel &&
  284. (Prompts->Count == 1) &&
  285. FLAGSET(int(Prompts->Objects[0]), pupRemember) &&
  286. DebugAlwaysTrue(IsPasswordOrPassphrasePrompt(Kind, Prompts)))
  287. {
  288. ShowSessionRememberPasswordPanel = true;
  289. }
  290. SavePasswordCheck->Checked = false;
  291. SavePasswordPanel->Visible = ShowSavePasswordPanel;
  292. SessionRememberPasswordCheck->Checked = false;
  293. SessionRememberPasswordPanel->Visible = ShowSessionRememberPasswordPanel;
  294. if (PasswordPanel->AutoSize)
  295. {
  296. PasswordPanel->AutoSize = false;
  297. PasswordPanel->AutoSize = true;
  298. }
  299. PasswordPanel->Realign();
  300. DebugAssert(Results->Count == Edits->Count);
  301. for (int Index = 0; Index < Edits->Count; Index++)
  302. {
  303. TCustomEdit * Edit = reinterpret_cast<TCustomEdit *>(Edits->Items[Index]);
  304. Edit->Text = Results->Strings[Index];
  305. }
  306. Result = Execute(Name, PasswordPanel,
  307. ((Edits->Count > 0) ?
  308. reinterpret_cast<TWinControl *>(Edits->Items[0]) :
  309. static_cast<TWinControl *>(PasswordOKButton)),
  310. PasswordOKButton, PasswordCancelButton, true, false, ForceLog);
  311. if (Result)
  312. {
  313. for (int Index = 0; Index < Edits->Count; Index++)
  314. {
  315. TCustomEdit * Edit = reinterpret_cast<TCustomEdit *>(Edits->Items[Index]);
  316. Results->Strings[Index] = Edit->Text;
  317. Prompts->Objects[Index] = (TObject *)
  318. ((int(Prompts->Objects[Index]) & ~pupRemember) |
  319. FLAGMASK(((Index == 0) && SessionRememberPasswordCheck->Checked), pupRemember));
  320. }
  321. if (SavePasswordCheck->Checked)
  322. {
  323. DebugAssert(Data != NULL);
  324. DebugAssert(Results->Count >= 1);
  325. FSessionData->Password = Results->Strings[0];
  326. Data->Password = Results->Strings[0];
  327. // modified only, explicit
  328. StoredSessions->Save(false, true);
  329. }
  330. }
  331. }
  332. __finally
  333. {
  334. delete Edits;
  335. }
  336. return Result;
  337. }
  338. //---------------------------------------------------------------------------
  339. void __fastcall TAuthenticateForm::UpdateBannerFont()
  340. {
  341. if (BannerMonospacedFontAction->Checked)
  342. {
  343. BannerMemo->Font->Name = CustomWinConfiguration->DefaultFixedWidthFontName;
  344. BannerMemo->Font->Size = CustomWinConfiguration->DefaultFixedWidthFontSize;
  345. }
  346. else
  347. {
  348. BannerMemo->ParentFont = true;
  349. }
  350. }
  351. //---------------------------------------------------------------------------
  352. void __fastcall TAuthenticateForm::Banner(const UnicodeString & Banner,
  353. bool & NeverShowAgain, int Options, unsigned int & Params)
  354. {
  355. BannerMemo->Lines->Text = Banner;
  356. NeverShowAgainCheck->Visible = FLAGCLEAR(Options, boDisableNeverShowAgain);
  357. NeverShowAgainCheck->Checked = NeverShowAgain;
  358. BannerMonospacedFontAction->Checked = FLAGSET(Params, bpMonospacedFont);
  359. UpdateBannerFont();
  360. bool Result = Execute(LoadStr(AUTHENTICATION_BANNER), BannerPanel, BannerCloseButton,
  361. BannerCloseButton, BannerCloseButton, false, true, false);
  362. if (Result)
  363. {
  364. NeverShowAgain = NeverShowAgainCheck->Checked;
  365. Params =
  366. (Params & ~bpMonospacedFont) |
  367. FLAGMASK(BannerMonospacedFontAction->Checked, bpMonospacedFont);
  368. }
  369. }
  370. //---------------------------------------------------------------------------
  371. bool __fastcall TAuthenticateForm::Execute(UnicodeString Status, TPanel * Panel,
  372. TWinControl * FocusControl, TButton * DefaultButton, TButton * CancelButton,
  373. bool FixHeight, bool Zoom, bool ForceLog)
  374. {
  375. TModalResult DefaultButtonResult;
  376. TAlign Align = Panel->Align;
  377. try
  378. {
  379. // If not visible yet, the animation was not even initialized yet
  380. if (Visible)
  381. {
  382. FFrameAnimation.Stop();
  383. }
  384. DebugAssert(FStatus.IsEmpty());
  385. FStatus = Status;
  386. DefaultButton->Default = true;
  387. CancelButton->Cancel = true;
  388. DefaultButtonResult = DefaultResult(this);
  389. if (Zoom)
  390. {
  391. Panel->Align = alClient;
  392. }
  393. if (ForceLog || Visible)
  394. {
  395. if (ClientHeight < Panel->Height)
  396. {
  397. ClientHeight = Panel->Height;
  398. }
  399. // Panel being hidden gets not realigned automatically, even if it
  400. // has Align property set
  401. Panel->Top = ClientHeight - Panel->Height;
  402. Panel->Show();
  403. TCursor PrevCursor = Screen->Cursor;
  404. try
  405. {
  406. if (Zoom)
  407. {
  408. TopPanel->Hide();
  409. }
  410. else
  411. {
  412. if (LogView->Items->Count > 0)
  413. {
  414. // To avoid the scrolling effect when setting TopIndex
  415. LogView->Items->BeginUpdate();
  416. try
  417. {
  418. MakeLogItemVisible(LogView->Items->Count - 1);
  419. }
  420. __finally
  421. {
  422. LogView->Items->EndUpdate();
  423. RedrawLog();
  424. }
  425. }
  426. }
  427. Screen->Cursor = crDefault;
  428. if (!Visible)
  429. {
  430. DebugAssert(ForceLog);
  431. ShowAsModal();
  432. }
  433. ActiveControl = FocusControl;
  434. ModalResult = mrNone;
  435. AdjustControls();
  436. do
  437. {
  438. Application->HandleMessage();
  439. }
  440. while (!Application->Terminated && (ModalResult == mrNone));
  441. }
  442. __finally
  443. {
  444. Panel->Hide();
  445. Screen->Cursor = PrevCursor;
  446. if (Zoom)
  447. {
  448. TopPanel->Show();
  449. }
  450. Repaint();
  451. }
  452. }
  453. else
  454. {
  455. int PrevHeight = ClientHeight;
  456. int PrevMinHeight = Constraints->MinHeight;
  457. int PrevMaxHeight = Constraints->MaxHeight;
  458. try
  459. {
  460. Constraints->MinHeight = 0;
  461. ClientHeight = Panel->Height;
  462. if (FixHeight)
  463. {
  464. Constraints->MinHeight = Height;
  465. Constraints->MaxHeight = Height;
  466. }
  467. TopPanel->Hide();
  468. Panel->Show();
  469. FFocusControl = FocusControl;
  470. ShowModal();
  471. }
  472. __finally
  473. {
  474. FFocusControl = NULL;
  475. ClientHeight = PrevHeight;
  476. Constraints->MinHeight = PrevMinHeight;
  477. Constraints->MaxHeight = PrevMaxHeight;
  478. Panel->Hide();
  479. TopPanel->Show();
  480. }
  481. }
  482. }
  483. __finally
  484. {
  485. Panel->Align = Align;
  486. DefaultButton->Default = false;
  487. CancelButton->Cancel = false;
  488. FStatus = L"";
  489. AdjustControls();
  490. FFrameAnimation.Start();
  491. }
  492. bool Result = (ModalResult == DefaultButtonResult);
  493. if (!Result)
  494. {
  495. // This is not nice as it may ultimately route to
  496. // TTerminalThread::Cancel() and throw fatal exception,
  497. // what actually means that any PromptUser call during authentication never
  498. // return false and their fall back/alternative code never occurs.
  499. // It probably needs fixing.
  500. DoCancel();
  501. }
  502. return Result;
  503. }
  504. //---------------------------------------------------------------------------
  505. void __fastcall TAuthenticateForm::HelpButtonClick(TObject * /*Sender*/)
  506. {
  507. FormHelp(this);
  508. }
  509. //---------------------------------------------------------------------------
  510. int __fastcall TAuthenticateForm::LogItemHeight(int Index)
  511. {
  512. UnicodeString S = LogView->Items->Strings[Index];
  513. TRect TextRect(0, 0, LogView->ClientWidth - (2 * FHorizontalLogPadding), 0);
  514. LogView->Canvas->Font = LogView->Font;
  515. LogView->Canvas->TextRect(TextRect, S, FLogTextFormat + (TTextFormat() << tfCalcRect));
  516. int Result = TextRect.Height() + (2 * FVerticalLogPadding);
  517. return Result;
  518. }
  519. //---------------------------------------------------------------------------
  520. void __fastcall TAuthenticateForm::LogViewMeasureItem(TWinControl * /*Control*/, int Index,
  521. int & Height)
  522. {
  523. Height = LogItemHeight(Index);
  524. }
  525. //---------------------------------------------------------------------------
  526. void __fastcall TAuthenticateForm::LogViewDrawItem(TWinControl * /*Control*/, int Index,
  527. TRect & Rect, TOwnerDrawState /*State*/)
  528. {
  529. // Reset back to base colors. We do not want to render selection.
  530. // + At initial phases the canvas font will not yet reflect he desktop font.
  531. LogView->Canvas->Font = LogView->Font;
  532. LogView->Canvas->Brush->Color = LogView->Color;
  533. LogView->Canvas->FillRect(Rect);
  534. // tfVerticalCenter does not seem to center the text,
  535. // so we need to deflate the vertical size too
  536. Rect.Inflate(-FHorizontalLogPadding, -FVerticalLogPadding);
  537. UnicodeString S = LogView->Items->Strings[Index];
  538. LogView->Canvas->TextRect(Rect, S, FLogTextFormat);
  539. }
  540. //---------------------------------------------------------------------------
  541. void __fastcall TAuthenticateForm::RedrawLog()
  542. {
  543. // Redraw including the scrollbar (RDW_FRAME)
  544. RedrawWindow(LogView->Handle, NULL, NULL, RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW);
  545. }
  546. //---------------------------------------------------------------------------
  547. void __fastcall TAuthenticateForm::FormResize(TObject * /*Sender*/)
  548. {
  549. if (LogView->Showing)
  550. {
  551. // Mainly to avoid the scrolling effect when setting TopIndex
  552. LogView->Items->BeginUpdate();
  553. try
  554. {
  555. // Rebuild the list view to force Windows to resend WM_MEASUREITEM
  556. int ItemIndex = LogView->ItemIndex;
  557. int TopIndex = LogView->TopIndex;
  558. std::unique_ptr<TStringList> Items(new TStringList);
  559. Items->Assign(LogView->Items);
  560. LogView->Items->Assign(Items.get());
  561. LogView->ItemIndex = ItemIndex;
  562. LogView->TopIndex = TopIndex;
  563. }
  564. __finally
  565. {
  566. LogView->Items->EndUpdate();
  567. RedrawLog();
  568. }
  569. }
  570. }
  571. //---------------------------------------------------------------------------
  572. void __fastcall TAuthenticateForm::ChangeScale(int M, int D)
  573. {
  574. TForm::ChangeScale(M, D);
  575. // Recreate the list to re-measure the items according to the new font
  576. if (DebugAlwaysTrue(LogView->HandleAllocated()) &&
  577. (LogView->Items->Count > 0))
  578. {
  579. std::unique_ptr<TStrings> Items(new TStringList());
  580. Items->AddStrings(LogView->Items);
  581. LogView->Items->Clear();
  582. LogView->Items->AddStrings(Items.get());
  583. MakeLogItemVisible(LogView->Items->Count - 1);
  584. }
  585. }
  586. //---------------------------------------------------------------------------
  587. void __fastcall TAuthenticateForm::BannerMemoContextPopup(TObject * Sender, TPoint & MousePos, bool & Handled)
  588. {
  589. MenuPopup(Sender, MousePos, Handled);
  590. }
  591. //---------------------------------------------------------------------------
  592. void __fastcall TAuthenticateForm::BannerMonospacedFontActionExecute(TObject * /*Sender*/)
  593. {
  594. BannerMonospacedFontAction->Checked = !BannerMonospacedFontAction->Checked;
  595. UpdateBannerFont();
  596. }
  597. //---------------------------------------------------------------------------