Howard Page-Clark wrote:
On 11/10/2013 22:00, Mark Morgan Lloyd wrote:

Given a TPageControl with several existing pages, how does one insert
a page at a specified position rather than at the end?

This function should do it:

uses ComCtrls;

function InsertAt(ExistingIndex: integer;
                  aPageControl: TPageControl): TTabSheet;
begin
  Result:=nil;
  if (ExistingIndex<0) or (ExistingIndex>aPageControl.PageCount-1) then
    Exit;
  Result:= aPageControl.AddTabSheet;
  if aPageControl.IndexOf(Result) <> ExistingIndex then
    TNBPages(TCustomTabControl(aPageControl).Pages).Move(
                aPageControl.IndexOf(Result), ExistingIndex);
end;

Thanks Howard, a slight variant of that is working. Any residual problems are my own doing :-)

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]

--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to