TPageControl.IndexofTabAt returning wrong values when some tabs are hidden.
Original Reporter info from Mantis: OldRuby
-
Reporter name: Colin Liebenrood
Original Reporter info from Mantis: OldRuby
- Reporter name: Colin Liebenrood
Description:
TPageControl.IndexofTabAt returning wrong values when some tabs are hidden.
Example: 16 tabs (0..15) with tabs 4..9 and 12 hidden. Mouse over tab 10 (5th visible) returns 11, should be 10.
The cause is in function TabIndexAtClientPos in file C:\lazarus\lcl\include\customnotebook.inc, where
the return vaule is calculated. The following rewrite of this function returns the correct value.
TCustomTabControl.TabIndexAtClientPos(ClientPos: TPoint): integer;
var
i, TabIx, VisiblePageInd: Integer;
begin
if HandleAllocated then begin
TabIx:=TWSCustomTabControlClass(WidgetSetClass).GetTabIndexAtPos(Self, ClientPos);
// TabIx is the index in visible tabs because invisible tabs are removed
// from the native control. Calculate the real tab index here.
VisiblePageInd:=-1;
for i:=0 to PageCount-1 do
if Page[i].TabVisible then begin
Inc(VisiblePageInd);
if VisiblePageInd = TabIx then begin
Result := i;
Break
end
end
end else
Result:=-1;
end;
Mantis conversion info:
- Mantis ID: 30343
- OS Build: 7 Professional
- Platform: Win32
- Version: 1.4.2
- Fixed in revision: r53950 (#f723ac55)
- Target version: 1.6.4