Authenticate.cpp 20 KB

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