Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TabVisible := False issue

376 views
Skip to first unread message

_Favour Pty Ltd

unread,
May 20, 2001, 7:56:14 PM5/20/01
to
Hi,

With a PageControl, I am setting one of the TabSheet's TabVisible property
to false. However I am getting the following error:

'..access violation EListError with message 'List index out of bounds(4)'

Can anyone tell me whether this sounds like a Tabsheet-type error, because I
cannot work out why this error should be occurring?

Thanks

Alex


David Novo

unread,
May 20, 2001, 9:14:36 PM5/20/01
to
Are you sure that you have 5 tabsheets (They start enumerating at zero)?

-Dave

Renate Schaaf

unread,
May 20, 2001, 9:21:46 PM5/20/01
to
In article <3b085acb_2@dnews>, _Favour Pty Ltd wrote:
> With a PageControl, I am setting one of the TabSheet's TabVisible property
> to false. However I am getting the following error:
>
> '..access violation EListError with message 'List index out of bounds(4)'
>

I think you didn't take into account that the page index is zero based:
tabsheet4=pagecontrol1.pages[3]. 'List index out of bounds' occurs whenever
you access an item in a list which hasn't been allocated. Could be one of
your lists, could be an internal list of a component such as
TPageControl.Pages or TWinControl.Controls.

Renate

_Favour Pty Ltd

unread,
May 20, 2001, 9:52:59 PM5/20/01
to
No I don't have 5 tabsheets but I cannot see why it is looking for a 5th
tabsheet. Here is my code snippet

for i := 0 to ActivePageControl.PageCount - 1 do begin
if trim(Tabs.Caption[ord(ActiveScreen),i+1]) = '' then begin
ActivePageControl.Pages[i].TabVisible := False;
end else begin
ActivePageControl.Pages[i].Tag := i+1;
ActivePageControl.Pages[i].Caption :=
Tabs.Caption[ord(ActiveScreen),i+1];
ActivePageControl.Pages[i].TabVisible := True
end;
end;

ActivePageControl is my current form. The error pops up at the TabVisible
:= False spot and it is only iterated up to the third tabsheet of four. If
I put a try...except within the loop, it then happily continues on to the
fourth iteration and successfully sets the caption of the fourth tabsheet.

The problem only seems to be when assigning the Tabsheet TabVisible propert
to False.

I can't work it out!

Thanks

Alex

"David Novo" <dnov...@ucla.edu> wrote in message
news:3B086BFB...@ucla.edu...

Bruce Roberts

unread,
May 20, 2001, 10:10:21 PM5/20/01
to

"_Favour Pty Ltd" <delete...@favour.com.au> wrote in message
news:3b0876f0_1@dnews...

> No I don't have 5 tabsheets but I cannot see why it is looking for a 5th
> tabsheet. Here is my code snippet
>
> for i := 0 to ActivePageControl.PageCount - 1 do begin
> if trim(Tabs.Caption[ord(ActiveScreen),i+1]) = '' then begin
> ActivePageControl.Pages[i].TabVisible := False;
> end else begin
> ActivePageControl.Pages[i].Tag := i+1;
> ActivePageControl.Pages[i].Caption :=
> Tabs.Caption[ord(ActiveScreen),i+1];
> ActivePageControl.Pages[i].TabVisible := True
> end;
> end;

1. What is Tabs.Caption?
2. Where/when is this code executed?

Jeff Overcash (TeamB)

unread,
May 20, 2001, 10:34:36 PM5/20/01
to
Do your for loop backwards. TabVisible := false has the side effect of setting
Visible := false for that TabSheet. Setting a TabSheet's Visible to false
removes it from the ActivePageControl's array so your Pages array is shrinking
as the loop progresses. Doing the loop backwards will keep the Pages in the
correct order for the duration of the loop.

_Favour Pty Ltd wrote:
>
> No I don't have 5 tabsheets but I cannot see why it is looking for a 5th
> tabsheet. Here is my code snippet
>
> for i := 0 to ActivePageControl.PageCount - 1 do begin
> if trim(Tabs.Caption[ord(ActiveScreen),i+1]) = '' then begin
> ActivePageControl.Pages[i].TabVisible := False;
> end else begin
> ActivePageControl.Pages[i].Tag := i+1;
> ActivePageControl.Pages[i].Caption :=
> Tabs.Caption[ord(ActiveScreen),i+1];
> ActivePageControl.Pages[i].TabVisible := True
> end;
> end;
>
> ActivePageControl is my current form. The error pops up at the TabVisible
> := False spot and it is only iterated up to the third tabsheet of four. If
> I put a try...except within the loop, it then happily continues on to the
> fourth iteration and successfully sets the caption of the fourth tabsheet.
>
> The problem only seems to be when assigning the Tabsheet TabVisible propert
> to False.
>
> I can't work it out!
>
> Thanks
>
> Alex
>


--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
Anyone who cannot cope with mathematics is not fully human.
At best he is a tolerable subhuman who has learned to wear
shoes, bathe and not make messes in the house. (Heinlein)

_Favour Pty Ltd

unread,
May 20, 2001, 11:02:14 PM5/20/01
to
Hi Bruce,

Tabs is just an array where I store various settings. Essentially if the
tab caption is blank, I want to hide the tabsheet.

I perform this code in the OnCreate event of a form, however, the assignment
is for a tabsheet on another form.

Cheers

Alex


"Bruce Roberts" <b...@attcanada.net> wrote in message
news:3b08790e$1_2@dnews...

_Favour Pty Ltd

unread,
May 20, 2001, 11:42:44 PM5/20/01
to
Hi Jeff,

I wasn't aware that the pages array shrinks. How would you get it back once
it disappears from the array?

I did try setting the loop backwards but tried again, and it did not solve
the problem. However, once I performed some pre-code to set all the
tabsheets visible to True it seemed to work to a certain extent. It still
comes up with the error but only when it is the last tabsheet on the page
control.

Even after hiding tabsheets, however, the PageControl.PageCount still
displays the total number of pages regardless of it being displayed or not.
Are you sure it disappears from the pages array?

I'm interested in the effects of Tabsheet.Visible. I understood this had no
effect on Tabsheets. Also this particular code was also present in our
previous product release which was Delphi 3 as opposed to Delphi 5 now. I
wonder whether there have been some changes in functionality.

Thanks for the info btw

Alex


"Jeff Overcash (TeamB)" <over...@onramp.net> wrote in message
news:3B087EBC...@onramp.net...

_Favour Pty Ltd

unread,
May 21, 2001, 4:13:55 AM5/21/01
to
Just to update anyone who may be interested,

I still had tremendous problems with the TabControl. So as a test I decided
to use another available 3rd party one called TabControl98, and it worked
like a dream. Seems to indicate some sort of bug in the Delphi 5 version of
TabControl.

Alex

"_Favour Pty Ltd" <delete...@favour.com.au> wrote in message

news:3b085acb_2@dnews...

Manuel Algora

unread,
May 21, 2001, 7:18:45 AM5/21/01
to
On Mon, 21 May 2001 13:42:44 +1000, "_Favour Pty Ltd"
<delete...@favour.com.au> wrote:

>I wasn't aware that the pages array shrinks. How would you get it back once
>it disappears from the array?

Visible or Not, you can always access a TabSheet by its name.

Manuel Algora
m...@encomix.es

Hans Plitzner

unread,
May 21, 2001, 7:52:57 AM5/21/01
to

_Favour Pty Ltd <delete...@favour.com.au> schrieb in im Newsbeitrag:
3b085acb_2@dnews...

Hi Alex,

try to override GetImageIndex like this:

procedure TForm.ExtPageControlGetImageIndex(Sender: TObject;
TabIndex: Integer; var ImageIndex: Integer);
begin
ImageIndex := -1;
end;

Hans

0 new messages