diff --git a/lcl/include/customnotebook.inc b/lcl/include/customnotebook.inc index 0e6a0e6261..42e519f261 100644 --- a/lcl/include/customnotebook.inc +++ b/lcl/include/customnotebook.inc @@ -449,6 +449,12 @@ begin Result := AIndex; if csDesigning in ComponentState then exit; //all pages are visible + + // it is possible to show pages without visible tabs, but then, no tab index + // can be sendet back, issue #21723 + if not Page[AIndex].TabVisible then + exit(-1); + for i := 0 to AIndex - 1 do begin if not Page[i].TabVisible then dec(Result); //exclude invisible page diff --git a/lcl/interfaces/gtk2/gtk2pagecontrol.inc b/lcl/interfaces/gtk2/gtk2pagecontrol.inc index 42e605247f..626f83666a 100644 --- a/lcl/interfaces/gtk2/gtk2pagecontrol.inc +++ b/lcl/interfaces/gtk2/gtk2pagecontrol.inc @@ -553,6 +553,9 @@ begin Exit; if (AIndex < 0) or (AIndex > ATabControl.PageCount - 1) then exit; + ANewIndex:=ATabControl.PageToTabIndex(AIndex); + if (ANewIndex < 0) then + exit; GtkNotebook := {%H-}PGtkNoteBook(ATabControl.Handle); if gtk_notebook_get_current_page(GtkNotebook) <> AIndex then begin