Re: [Lazarus] Inserting new pages into a TPageControl

2013-10-13 Thread Mark Morgan Lloyd

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
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Inserting new pages into a TPageControl

2013-10-13 Thread Howard Page-Clark

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;



--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Inserting new pages into a TPageControl

2013-10-11 Thread Mark Morgan Lloyd
Assuming that TPageControl remains the preferred way to organise a 
tabbed "notebook", I'm left with porting some older code and also trying 
to tune something I'm currently working on. I'm trying to stick to 
Lazarus 1.0, since particularly if I publish a program as being of use 
to non-Lazarus developers (e.g. an RJE workstation for the IBM mainframe 
crowd) I think that sticking to a major release is a benefit.


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


--
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
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus