[SOLVED] ATTabs howto, OptShowXButtons := atbxShowActive, but not on last tab lazarus / 31-LCL ---------------------------------------------------------------------- d7_2_laz · 2021-03-04 17:52 How to achieve the following aims alltogether correctly? -  show close button, but only on the active tab (OptShowXButtons := atbxShowActive) -  but not on the last tab opened (don't close last opened tab), ie. with atbxShowNone depending on the TabCount -  After the tab originally had been created with a provisional caption text; somehow by AddTab(-1, 'something', ... -  then afterwards the app should be able to redefine the caption with another text ..... Data.TabCaption := 'yy' Very Roughly condensed somehow like: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Data :=  FATtabs.AddTab(-1, 'something', ts, False, clSilver, FTabImageIndex);FATtabs.OptShowXButtons := atbxShowNone;   // init setting had been atbxShowActive// and later, triggered from some event:Data.TabCaption := 'yy'; Should that work? At me (without code patch) it results in an unexpected rectangle calculation, see picture. ---------------------------------------------------------------------- AlexTP · 2021-03-04 18:32 TATTabData (use TATTabs.GetTabData method to get it) has the property TabHideXButton. So try to set it. ---------------------------------------------------------------------- AlexTP · 2021-03-04 18:36 Quotethen afterwards the app should be able to redefine the caption with another text Demo program does it, it changes tab's caption by changing the TEdit. d:= mytabs.GetTabData(N), then it changes d.TabCaption, then calls mytabs.Invalidate. ---------------------------------------------------------------------- d7_2_laz · 2021-03-04 19:38 Data.TabCaption works fine, but not the TextRect within my demo tabs.OptShowXButtons := atbxShowNone  and  Data.TabHideXButton:=True behave equally in this context. See example.jpg.  Without TabHideXButton: see example_ok.jpg Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   Data :=  FATtabs.AddTab(-1, 'something', ts, False, clSilver, FTabImageIndex);   // Data: TATTabData;    // Both are behaving equally here::  //FATtabs.OptShowXButtons := atbxShowNone;  Data.TabHideXButton := True;   // And later ...:  S := 'yy ';  Data.TabCaption := S;  FATtabs.Invalidate;  // test-only, should be called internally Again it must be something trivia. ,But it appears to me as if the width for the close button area is subtracted from the textwidth twice when recalculating the space. If needed i add the slightly adapted testcase here. ---------------------------------------------------------------------- AlexTP · 2021-03-04 20:16 Yes, pls add  the testcase here. Compilable demo. ---------------------------------------------------------------------- d7_2_laz · 2021-03-04 20:25 Attached. 'For Lazarus/Windows.  Pls. note, the lines mentioned are a simplification from the intended flow. - Hopefully it's my own error. But i'm interested to learn how it is intended to work. ---------------------------------------------------------------------- AlexTP · 2021-03-04 20:53 Good! Fixed a bug-- UpdateTabRects ignored 'space between icon and caption'. Pls test again, get from Github. ---------------------------------------------------------------------- AlexTP · 2021-03-04 21:08 Another little bug is black pixels (black pixels matter) on tab corners. You can do OptTabRounded:= false; but I cannot solve it with "true". Maybe your testcase settings matter? any small demo? ---------------------------------------------------------------------- d7_2_laz · 2021-03-04 21:18 Yes Alextp, that's it!    Works exactly as expected at that point for the steps mentioned  (using either tabs.OptShowXButtons or Data.TabHideXButton. Thousand thanks for your superfast solution, that is very impressive! ---------------------------------------------------------------------- AlexTP · 2021-03-04 21:32 I fixed corner black pixels-- ParentColor is set to false. you need to set more colors in testcase. ---------------------------------------------------------------------- d7_2_laz · 2021-03-04 21:43 About the black corner thing: "you need to set more colors in testcase." .. could you explain this a bit? I found another little glitch too. That would be part of my second (and hopefully last) howto question here,  maybe tomorrow. I'll try to describe it as best i can. ---------------------------------------------------------------------- AlexTP · 2021-03-05 09:46 Of coz. before: you don't set ftabs.Color, it's from parent (ParentColor=true). now: you need to set ftabs.Color, because ParentColor is now false. ---------------------------------------------------------------------- d7_2_laz · 2021-03-05 11:37 Oh, see that with the today's github version ..... ok, thank you! ---------------------------------------------------------------------- AlexTP · 2021-03-05 11:46 Consider (feel free) to report any further issues, too. ---------------------------------------------------------------------- d7_2_laz · 2021-03-05 15:04 Thank you Alextp, it's very appreciated! Meanwhile it's hard for me to find more of them  .... it simply works smooth