lcl: add public property TCustomListView.ColumnCount,

win32: don't access listview columns array out of it bounds (issue #0017263)

git-svn-id: trunk@27199 -
This commit is contained in:
paul 2010-08-26 16:39:45 +00:00
parent bdf98dfd4f
commit f20f3aa1ef
3 changed files with 8 additions and 1 deletions

View File

@ -1041,6 +1041,7 @@ type
FOnAdvancedCustomDrawSubItem: TLVAdvancedCustomDrawSubItemEvent;
FProperties: TListViewProperties;
function GetBoundingRect: TRect;
function GetColumnCount: Integer;
function GetColumnFromIndex(AIndex: Integer): TListColumn;
function GetDropTarget: TListItem;
function GetFocused: TListItem;
@ -1155,6 +1156,7 @@ type
property Canvas: TCanvas read FCanvas;
property Checkboxes: Boolean index Ord(lvpCheckboxes) read GetProperty write SetProperty default False;
property Column[AIndex: Integer]: TListColumn read GetColumnFromIndex;
property ColumnCount: Integer read GetColumnCount;
property DropTarget: TListItem read GetDropTarget write SetDropTarget;
property FlatScrollBars: Boolean index Ord(lvpFlatScrollBars) read GetProperty write SetProperty default False;
property FullDrag: Boolean index Ord(lvpFullDrag) read GetProperty write SetProperty default False;

View File

@ -725,6 +725,11 @@ begin
else Result := TWSCustomListViewClass(WidgetSetClass).GetBoundingRect(Self);
end;
function TCustomListView.GetColumnCount: Integer;
begin
Result := FColumns.Count;
end;
function TCustomListView.GetColumnFromIndex(AIndex: Integer): TListColumn;
begin
Result := FColumns[AIndex];

View File

@ -678,7 +678,7 @@ begin
// We will therefore postpone all autosizing until EndUpdate where we do
// it only once per column.
if ALV.Column[ASubIndex].AutoSize and (TCustomListViewAccess(ALV).GetUpdateCount = 0) then
if (ASubIndex >= 0) and (ASubIndex < ALV.ColumnCount) and ALV.Column[ASubIndex].AutoSize and (TCustomListViewAccess(ALV).GetUpdateCount = 0) then
ListView_SetColumnWidth(ALV.Handle, ASubIndex, AutoSizeWidth);
end;