Skip to content

Commit

Permalink
fix listview erroring out when creating using lua in dark mode
Browse files Browse the repository at this point in the history
  • Loading branch information
cheat-engine committed May 9, 2021
1 parent bb56f14 commit b5313a6
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion Cheat Engine/betterControls/newlistview.pas
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ TNewListView=class(ComCtrls.TListView)
function CustomDraw(const ARect: TRect; AStage: TCustomDrawStage): Boolean; override;
function CustomDrawItem(AItem: TListItem; AState: TCustomDrawState; AStage: TCustomDrawStage): Boolean; override;
function CustomDrawSubItem(AItem: TListItem; ASubItem: Integer; AState: TCustomDrawState; AStage: TCustomDrawStage): Boolean; override;

procedure SetParent(NewParent: TWinControl); override;
public
published
property ViewStyle: TViewStyle read getViewStyle write setViewStyle;
Expand All @@ -55,6 +57,23 @@ implementation
uses betterControls;


procedure TNewListView.SetParent(NewParent: TWinControl);
var h: tHandle;
begin
inherited SetParent(newparent);

if (parent<>nil) and (viewstyle=vsReport) and (not (csReadingState in ControlState)) then
begin
h:=ListView_GetHeader(handle);
if (h<>0) and (h<>INVALID_HANDLE_VALUE) then
begin
AllowDarkModeForWindow(h, 1);
SetWindowTheme(h, 'ItemsView',nil);
end;
end;

end;

procedure TNewListView.setViewStyle(style: TViewStyle);
var
h: THandle;
Expand All @@ -69,7 +88,7 @@ procedure TNewListView.setViewStyle(style: TViewStyle);
begin
cs:=ControlState;

if (olds<>style) and (style=vsReport) and (not (csReadingState in cs)) then
if (parent<>nil) and (olds<>style) and (style=vsReport) and (not (csReadingState in cs)) then
begin
h:=ListView_GetHeader(handle);
if (h<>0) and (h<>INVALID_HANDLE_VALUE) then
Expand Down

0 comments on commit b5313a6

Please sign in to comment.