In the attached project I have a TPageControl with 6 pages. Of these the 'odd' numbered pages (1, 3, 5) are visible, and the even number pages (pages 2, 4, 6) are invisible. My goal is that when an odd numbered page (page O) is selected, the next (even numbered) page will also become visible, and capable of selection.
The initial condition is that Pages 1, 3, 5 are visible.
Select - for example - Page 3.
The desired result is that Pages 1, 3, 4, 5 are now visible.
Select - for example - Page 1
The desired result is that Pages 1, 2, 3, 5 are now visible.
The TPageControl has an unpublished (but public) property Pages, which returns a TTabSheet. This is where the visible/invisible property is located. The code I am using for the OnChange event of the TPage control is as follows:
{We assume for now that there are 6 pages and only the odd pages are visible }
procedure TForm1.mpMultiPageAccessLabChange(Sender: TObject);
var
p : integer;
begin
{ Determine the active page, and then, if it is even (0,2,4) make all
the odd pages invisible, and then make the 'next' page (1,3,5) visible.
If the active page is 1,3,5, keep it visible. }
p := mpMultiPageAccessLab.ActivePageIndex;
showmessage ('Active Page is ' + format('%d',[p+1]) +', show sheet ' +
format('%d',[p+2]));
case p of
0,2,4 : begin
mpMultiPageAccessLab.pages(1).TabVisible := false;
mpMultiPageAccessLab.pages(3).TabVisible := false;
mpMultiPageAccessLab.pages(5).TabVisible := false;
mpMultiPageAccessLab.pages(p+1).TabVisible := true;
end;
1,3,5 : begin
mpMultiPageAccessLab.pages(p).TabVisible := true;
end;
end;
end;
When I try and compile this I get two errors:
Wrong number of parameters specified for call to GetTabSheet
Found Declaration GetTabSheet(LongInt) : TTabSheet
The first of these error messages occurs in the event handler at the first attempt to references pages(1);
The second error occurs in the code for pagecontrol.inc, where the following declaration is made:
function TPageControl.GetTabSheet(Index: Integer): TTabSheet;
begin
Result:=TTabSheet(inherited Page[Index]);
end;
I believe this declaration is part of the LCL unit, so it is not anything that I have concocted!
I'm struck by:
a) The compiler reports (I think) that the call to GetTabSheet requires a LongInt parameter, but the actual declaration requires an integer parameter.
b) The declaration (in pagecontrol.inc) requires only one parameter, which I am supplying, but the compiler complains that I have the wrong number of parameters.
Commenting out the case statement (where the errors are located) gives me exactly the response I want to implement.
At this point I feel a small surge of assertiveness arising within my normally cautious breast, which leads me to say "It may be unpublished, but I'm using the documented version of pages - even if it seems to do strange stuff under the covers".
Can someone (James?) enlighten me as to how I can accomplish what I want to accomplish? (viz that when I click on an 'odd numbered' page, the following page comes into view, and any other even-numbered page disappears)?
And where is the solution described and documented?
Thanks,
Tony