View Issue Details

IDProjectCategoryView StatusLast Update
0023251LazarusLCLpublic2013-10-21 20:18
Reporterchronos Assigned ToMartin Friebe  
Status closedResolutionfixed 
Product Version1.1 (SVN) 
Target Version1.2.0Fixed in Version1.1 (SVN) 
Summary0023251: PageControl page TabVisible not update PageIndex properly
DescriptionThere is problem in TCustomPage.SetTabVisible in code because PageIndex should correspond to index of visible tabs.
If some hidden tab placed to the left of current selected tab is shown then TPageControl.PageIndex is not properly updated and PageControl show content of one page but with different selected tab. In this faulty state setting TPageControl.PageIndex to right index not work because PageIndex is not different and thus not doing anything. Working workaround is to reset PageIndex to -1 and then set it back to right index.

Take a look at sample project and fix patch.
TagsNo tags attached.
Fixed in Revision42699
Attached Files


related to 0022293 closedLuiz Americo PageControl with hidden pages, fails to move pages 
related to 0021723 new TPageControl shows incorrect tab if individual tabs' TabVisible property is false 
related to 0023648 resolvedJuha Manninen TPageControl page disappear (only) in design time 


2012-10-31 12:25 (617 bytes)   
Index: lcl/include/
--- lcl/include/	(revision 39207)
+++ lcl/include/	(working copy)
@@ -68,6 +68,9 @@
       // check if there was no visible tab
       if TCustomTabControl(Parent).PageIndex = -1 then
+      if TCustomTabControl(Parent).PageIndex >= Self.PageIndex then
+        TCustomTabControl(Parent).PageIndex := TCustomTabControl(Parent).PageIndex + 1;
       // Check if the page is active and set a new pageindex (617 bytes)   

2012-10-31 12:26



2012-11-01 15:59

reporter   ~0063610

There are more problems in implementation of hidden tabs in PageControl.
Another bad situation is when page is set TabVisible to False and there are some other not selected tabs to the right of current tab. After tab is hidden no tab is visible at all.

Another weird situation is related to difference between TabIndex and PageIndex of TCustomTabControl. As I understand TabIndex should be index of visible tabs while PageIndex should be index of all pages include invisible ones. Then why property TabIndex points to same variable and method as PageIndex property?

Juha Manninen

2013-01-13 00:29

developer   ~0064841

It works so I applied it after some formatting/refactoring.
Thanks, and sorry for the delay.

Juha Manninen

2013-01-17 09:55

developer   ~0064941

Last edited: 2013-01-17 10:10

I reverted the change.
PageControl does not work when the IDE itself is built for GTK2.
Now, it was not caused by this issue but was broken already earlier. Someone please find the exact revision that broke it.
I will reapply this patch when all else if working.

Juha Manninen

2013-01-19 01:22

developer   ~0065000

Patch reapplied.


2013-01-19 20:12

reporter   ~0065013


Martin Friebe

2013-09-05 23:57

manager   ~0069758

The patch is wrong and the error still present (I am reverting it)

- pagecontrol with 5 pages, (1 to 5)
- page2 with tab hidden
- page4 selected

at runtime, press a button, that will set the tabVisible:=true for page2
=> the content of page 5 will be visible (w32 vista)

In any case a page is always in the list of pages, independent of the TabVisible.

Therefore TabVisible does not change the index.

If the wrong page is shown afterwards, then it most likely is a widgetset issue.

Juha Manninen

2013-09-08 10:04

developer   ~0069802

I don't know how to fix this. Assigning to Martin.

Martin Friebe

2013-09-09 13:29

manager   ~0069844

Please test and close if ok.

As for the note in the original description:

"PageIndex should correspond to index of visible tabs."

It does not. "Pages" always contains all tabs (independent of TabVisible). PageIndex is an index into that list.

Page[x].TabIndex (readonly) relates to visible tabs only

From the sample project:
  PageControl1.PageIndex := 1;
  TabSheet2.TabVisible := True;

Setting PageIndex to a page with a hidden tab.

Assuming, the TabVisible would not be changed to true after this (not the case here, just a side note):
Windows can actually display the page, even if the Tab is not visible. I have not checked if that works with all widgetsets. Also it may not be well defined which tab should be highlighted, if such a page was shown. But this is/was not part of this issue itself.

Issue History

Date Modified Username Field Change
2012-10-31 12:25 chronos New Issue
2012-10-31 12:25 chronos File Added:
2012-10-31 12:26 chronos File Added: PageControl Tab switch
2012-10-31 21:32 Juha Manninen Relationship added related to 0022293
2012-10-31 21:35 Juha Manninen Relationship added related to 0021723
2012-11-01 15:59 chronos Note Added: 0063610
2013-01-11 21:48 Juha Manninen Status new => assigned
2013-01-11 21:48 Juha Manninen Assigned To => Juha Manninen
2013-01-13 00:29 Juha Manninen Fixed in Revision => r39837
2013-01-13 00:29 Juha Manninen LazTarget => -
2013-01-13 00:29 Juha Manninen Status assigned => resolved
2013-01-13 00:29 Juha Manninen Resolution open => fixed
2013-01-13 00:29 Juha Manninen Note Added: 0064841
2013-01-17 00:19 Juha Manninen Relationship added related to 0023648
2013-01-17 09:55 Juha Manninen Status resolved => assigned
2013-01-17 09:55 Juha Manninen Resolution fixed => reopened
2013-01-17 09:55 Juha Manninen Note Added: 0064941
2013-01-17 10:10 Juha Manninen Note Edited: 0064941
2013-01-19 01:22 Juha Manninen Fixed in Revision r39837 => r39837, r39883
2013-01-19 01:22 Juha Manninen Status assigned => resolved
2013-01-19 01:22 Juha Manninen Resolution reopened => fixed
2013-01-19 01:22 Juha Manninen Note Added: 0065000
2013-01-19 20:12 chronos Status resolved => closed
2013-01-19 20:12 chronos Note Added: 0065013
2013-09-05 23:57 Martin Friebe Note Added: 0069758
2013-09-05 23:57 Martin Friebe Status closed => assigned
2013-09-05 23:57 Martin Friebe Resolution fixed => reopened
2013-09-08 10:03 Juha Manninen Assigned To Juha Manninen => Martin Friebe
2013-09-08 10:04 Juha Manninen Note Added: 0069802
2013-09-09 13:29 Martin Friebe Fixed in Revision r39837, r39883 => 42699
2013-09-09 13:29 Martin Friebe LazTarget - => 1.2
2013-09-09 13:29 Martin Friebe Note Added: 0069844
2013-09-09 13:29 Martin Friebe Status assigned => resolved
2013-09-09 13:29 Martin Friebe Fixed in Version => 1.1 (SVN)
2013-09-09 13:29 Martin Friebe Resolution reopened => fixed
2013-09-09 13:29 Martin Friebe Target Version => 1.2.0
2013-10-21 20:18 chronos Status resolved => closed