Recent

Author Topic: A Bug in TTabControl OnGetImageIndex Event  (Read 4088 times)

RobinHoo

  • New Member
  • *
  • Posts: 10
A Bug in TTabControl OnGetImageIndex Event
« on: December 25, 2009, 04:05:22 am »
Hi, All

I don't know how to apply an account to login the bug report system. But I did find a bug in TTabControl for showing the image icon on the tabs. TTabControl should display the icon in the imagelist according to the tab number. But it doesn't,it always show the first image in the imagelist event your create your own OnGetImageIndex eventhandler function. I checked around and found the problem was in the TCustomTabControl.GetImageIndex, and the defination of TTabGetImageEvent. The original and fixed code lines are shown as bellow. And after modifed the lcl source and recompiled lcl and lazarus with clear all. Bug fixed.

file:$lazarus/lcl/include/tabcontrol.inc[Line:482-487]
Code: [Select]
function TCustomTabControl.GetImageIndex(ATabIndex: Integer): Integer;
begin
  Result := TabIndex;
  if Assigned(FOnGetImageIndex) then
    FOnGetImageIndex(Self, TabIndex, Result);
end;
file:$lazarus/lcl/extctrls.pp[Line:130-131]
Code: [Select]
  TTabGetImageEvent = procedure(Sender: TObject; TabIndex: Integer;
    var ImageIndex: Integer) of object;

Fixed Code Lines
file:$lazarus/lcl/include/tabcontrol.inc[Line:482-487]
Code: [Select]
function TCustomTabControl.GetImageIndex(ATabIndex: Integer): Integer;
begin
  Result := ATabIndex;
  if Assigned(FOnGetImageIndex) then
    FOnGetImageIndex(Self, ATabIndex, Result);
end;
file:$lazarus/lcl/extctrls.pp[Line:130-131]
Code: [Select]
  TTabGetImageEvent = procedure(Sender: TObject; aTabIndex: Integer;
    var ImageIndex: Integer) of object;