mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-27 22:57:14 +01:00
win32: fix TListView.Autosize by Bernd Kreuss (issue #0017141)
git-svn-id: trunk@27046 -
This commit is contained in:
parent
2012316840
commit
2c127c9897
@ -1107,6 +1107,7 @@ type
|
|||||||
function CustomDrawItem(AItem: TListItem; AState: TCustomDrawState; AStage: TCustomDrawStage): Boolean; virtual; //
|
function CustomDrawItem(AItem: TListItem; AState: TCustomDrawState; AStage: TCustomDrawStage): Boolean; virtual; //
|
||||||
function CustomDrawSubItem(AItem: TListItem; ASubItem: Integer; AState: TCustomDrawState; AStage: TCustomDrawStage): Boolean; virtual; //
|
function CustomDrawSubItem(AItem: TListItem; ASubItem: Integer; AState: TCustomDrawState; AStage: TCustomDrawStage): Boolean; virtual; //
|
||||||
function IntfCustomDraw(ATarget: TCustomDrawTarget; AStage: TCustomDrawStage; AItem, ASubItem: Integer; AState: TCustomDrawState; const ARect: PRect): TCustomDrawResult;
|
function IntfCustomDraw(ATarget: TCustomDrawTarget; AStage: TCustomDrawStage; AItem, ASubItem: Integer; AState: TCustomDrawState; const ARect: PRect): TCustomDrawResult;
|
||||||
|
function GetUpdateCount: Integer;
|
||||||
|
|
||||||
procedure DoGetOwnerData(Item: TListItem); virtual;
|
procedure DoGetOwnerData(Item: TListItem); virtual;
|
||||||
protected
|
protected
|
||||||
|
|||||||
@ -521,6 +521,11 @@ begin
|
|||||||
then Result := [cdrSkipDefault];
|
then Result := [cdrSkipDefault];
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCustomListView.GetUpdateCount: Integer;
|
||||||
|
begin
|
||||||
|
Result := FUpdateCount;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCustomListView.DoGetOwnerData(Item: TListItem);
|
procedure TCustomListView.DoGetOwnerData(Item: TListItem);
|
||||||
begin
|
begin
|
||||||
if Assigned(OnData) then OnData(Self, Item);
|
if Assigned(OnData) then OnData(Self, Item);
|
||||||
|
|||||||
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
{ TWin32WSCustomListView }
|
{ TWin32WSCustomListView }
|
||||||
const
|
const
|
||||||
AutoSizeWidth = LVSCW_AUTOSIZE{_USEHEADER};
|
AutoSizeWidth = LVSCW_AUTOSIZE_USEHEADER;
|
||||||
|
|
||||||
type
|
type
|
||||||
TLVStyleType = (lsStyle, lsInvert, lsExStyle);
|
TLVStyleType = (lsStyle, lsInvert, lsExStyle);
|
||||||
@ -673,9 +673,13 @@ begin
|
|||||||
{$else}
|
{$else}
|
||||||
ListView_SetItemText(ALV.Handle, AIndex, ASubIndex, PChar(AText));
|
ListView_SetItemText(ALV.Handle, AIndex, ASubIndex, PChar(AText));
|
||||||
{$endif}
|
{$endif}
|
||||||
if ALV.Column[ASubIndex].AutoSize then begin
|
// autosize is an *exteme* performance bottleneck, even if WM_SETREDRAW
|
||||||
ListView_SetColumnWidth(ALV.Handle, ASubIndex, LVSCW_AUTOSIZE);
|
// was set to false it will ignore this and still redraw all columns.
|
||||||
end;
|
// 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
|
||||||
|
ListView_SetColumnWidth(ALV.Handle, ASubIndex, AutoSizeWidth);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TWin32WSCustomListView.ItemShow(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const PartialOK: Boolean);
|
class procedure TWin32WSCustomListView.ItemShow(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const PartialOK: Boolean);
|
||||||
@ -731,11 +735,29 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TWin32WSCustomListView.EndUpdate(const ALV: TCustomListView);
|
class procedure TWin32WSCustomListView.EndUpdate(const ALV: TCustomListView);
|
||||||
|
var
|
||||||
|
ColIndex : Integer;
|
||||||
begin
|
begin
|
||||||
if not WSCheckHandleAllocated(ALV, 'EndUpdate')
|
if not WSCheckHandleAllocated(ALV, 'EndUpdate')
|
||||||
then Exit;
|
then Exit;
|
||||||
|
|
||||||
|
// we have skipped all column resizing in ItemSetText()
|
||||||
|
// for performance reasons, so now we need to do it here.
|
||||||
|
//
|
||||||
|
// A further significant perfomance boost and reduced flickering
|
||||||
|
// can be achieved by setting the widget to invisible during the
|
||||||
|
// following operation (it ignores the state of WM_SETREDRAW for
|
||||||
|
// column resizing, but this way we we can really enforce it).
|
||||||
|
// ShowWindow() itself does not force an immediate redraw,
|
||||||
|
// so it won't flicker at all.
|
||||||
|
ShowWindow(ALV.Handle, SW_HIDE);
|
||||||
|
for ColIndex := 0 to TCustomListViewAccess(ALV).Columns.Count - 1 do
|
||||||
|
if ALV.Column[ColIndex].AutoSize then
|
||||||
|
ListView_SetColumnWidth(ALV.Handle, ColIndex, AutoSizeWidth);
|
||||||
|
|
||||||
SendMessage(ALV.Handle,WM_SETREDRAW,WPARAM(True),0);
|
SendMessage(ALV.Handle,WM_SETREDRAW,WPARAM(True),0);
|
||||||
|
if ALV.Visible then
|
||||||
|
ShowWindow(ALV.Handle, SW_SHOW);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class function TWin32WSCustomListView.GetBoundingRect(const ALV: TCustomListView): TRect;
|
class function TWin32WSCustomListView.GetBoundingRect(const ALV: TCustomListView): TRect;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user