Browse Source

Bug fix: Tab close button of new session was drawn as clicked, if it was opened from Login dialog popped up after the last session was closed by clicking its close button

Caused by fb28d236

Source commit: 7aa4f9ac8b06fb982491cf2b3c85926a5ead8376
Martin Prikryl 2 years ago
parent
commit
fb09f329e4
2 changed files with 14 additions and 0 deletions
  1. 13 0
      source/components/ThemePageControl.cpp
  2. 1 0
      source/components/ThemePageControl.h

+ 13 - 0
source/components/ThemePageControl.cpp

@@ -130,6 +130,7 @@ void TThemeTabSheet::UpdateCaption()
     }
   }
   Caption = ACaption;
+  ParentPageControl->TabChanged(TabIndex);
 }
 //----------------------------------------------------------------------------------------------------------
 UnicodeString TThemeTabSheet::GetBaseCaption()
@@ -519,6 +520,18 @@ bool TThemePageControl::IsHotButton(int Index)
   return (Index == FClickedButton) || (Index == FHotTabButton);
 }
 //----------------------------------------------------------------------------------------------------------
+void TThemePageControl::TabChanged(int Index)
+{
+  // When the "clicked" tab changes, it's probably not anymore the tab that was actually clicked.
+  // For example, when the last tab is closed, it's replaced with either local-local tab (without the X button),
+  // or removed altogether. The Login dialog pops up and when new session is opened, its tab's X button is rendered clicked,
+  // until connection openning finishes (and WMLButtonDown finishes).
+  if (Index == FClickedButton)
+  {
+    UpdateHotButton(FClickedButton, -1);
+  }
+}
+//----------------------------------------------------------------------------------------------------------
 void TThemePageControl::UpdateHotButton(int & Ref, int Index)
 {
   if (Ref != Index)

+ 1 - 0
source/components/ThemePageControl.h

@@ -65,6 +65,7 @@ protected:
   DYNAMIC void __fastcall Change();
   DYNAMIC void __fastcall MouseMove(TShiftState Shift, int X, int Y);
   virtual void __fastcall Dispatch(void * Message);
+  void TabChanged(int Index);
   #ifdef _DEBUG
   virtual void __fastcall RequestAlign();
   #endif