SilverpointDev / sptbxlib

SpTBXLib is an expansion package for TB2K Delphi components that adds multiple features including support for styles and custom skins.
https://www.silverpointdevelopment.com
Other
72 stars 33 forks source link

can not put a TButton on TSpTBXTabSet #109

Closed mksjgj closed 11 months ago

mksjgj commented 11 months ago

reproduce step: 1.create a new VCL Application 2.put a TSpTBXTabSet on Form1 3.double click SpTBXTabSet1, add two TSpTBXTabItem with caption "AAA", "BBB" 4.put a TButton on TSpTBXTabSet, with caption Button1 5.run the application , you will get an error UI: "BBB" and "Button1" disappeared

TabSetBug_.zip

SilverpointDev commented 11 months ago

Change this on TSpTBXTabToolbar.RightAlignItems:

    if Assigned(Spacer) then
      TSpTBXCustomItemAccess(Spacer.Item).CustomWidth := SpacerW;

    View.UpdatePositions;

Change it to:

    if Assigned(Spacer) then begin
      TSpTBXCustomItemAccess(Spacer.Item).CustomWidth := SpacerW;
      View.UpdatePositions;
    end;
mksjgj commented 11 months ago

I apply your fix, but it still has error if i put a SpTBXRightAlignSpacerItem1 before the Button1 01 design time 02 runtime 03 error box

 

------------------ 原始邮件 ------------------ 发件人: "SilverpointDev/sptbxlib" @.>; 发送时间: 2023年10月2日(星期一) 晚上9:56 @.>; @.**@.>; 主题: Re: [SilverpointDev/sptbxlib] can not put a TButton on TSpTBXTabSet (Issue #109)

Change this on TSpTBXTabToolbar.RightAlignItems: if Assigned(Spacer) then TSpTBXCustomItemAccess(Spacer.Item).CustomWidth := SpacerW; View.UpdatePositions;

Change it to: if Assigned(Spacer) then begin TSpTBXCustomItemAccess(Spacer.Item).CustomWidth := SpacerW; View.UpdatePositions; end;

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

SilverpointDev commented 11 months ago

Try this:

if Assigned(Spacer) then begin
  for I := 0 to View.ViewerCount - 1 do begin
    IV := View.Viewers[I];
    if IV.Item is TTBControlItem then
      if not IV.Show then
        Exit
      else
        if IV.BoundsRect.IsEmpty then
          Exit;
  end;

  TSpTBXCustomItemAccess(Spacer.Item).CustomWidth := SpacerW;
  View.UpdatePositions;
end;
mksjgj commented 11 months ago

It seems OK now, except a more polished fix/new version.

SilverpointDev commented 11 months ago

Fixed on latest commit