Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

Chow to control where a New tab is created win a space zone

My app uses Tabs in a space zone to simulate a tabbed page control.  3 of these tabs will be fixed but I need to programatically add additional tabs to the right hand end of fixed Tabs.
Currently the additional tabs are added one tab in from the right-hand end.   Is it possible to ensure that additional tabs appear at the end of existing tabs.

This is my routine to add a tab:
function TfmIDEMain.CreateBottomDock: TLMDDockPanel;
var SrchRes: TfmSearchResults;
    zn: TLMDDockZone;
begin
  Result := TLMDDockPanel.Create(Self); // Create new Panel
  try
    SrchRes := TfmSearchResults.Create(Result);
    SrchRes.Parent := Result;
    zn := dsBottom.SpaceZone;
    while (zn <> nil) and (zn.Kind <> zkTabs) and (zn.ZoneCount > 0) do
      zn := zn[0];
    if zn <> nil then
      dsBottom.DockControl(Result, zn, alClient, zn.ZoneCount -1);
  except
    On E: Exception do
      E.Free;
  end;
end;
Tagged:

Comments

  • 2 Comments sorted by Votes Date Added
  • edited November 2022 Posts: 0 Accepted Answer Vote Up1Vote Down
    Hi,

    ZoneCount is a counting value, it's not an index, so it is not appropriate to say "zero-based" or "one-based" about it.

    But, you right, when you want to add a new rightmost tab, you have to specify ZoneCount as an index. For example, suppose you have three existing zones. ZoneCount = 3, zone indices are: 0, 1 and 2. The next (rightmost) zone index will be 3, which is equal to the current ZoneCount.
  • just figured it out 

       dsBottom.DockControl(Result, zn, alClient, zn.ZoneCount

    Use Zone count not zone count -1  I had assumed the count would be 0 based.
Sign In or Register to comment.