unit Unit20;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, UxTheme;
type
TForm20 =
class(TForm)
lvRecentFiles: TListView;
procedure lvRecentFilesDrawItem(Sender: TCustomListView; Item: TListItem;
Rect: TRect; State: TOwnerDrawState);
procedure lvRecentFilesCustomDraw(Sender: TCustomListView;
const ARect: TRect;
var DefaultDraw: Boolean);
procedure lvRecentFilesCustomDrawItem(Sender: TCustomListView;
Item: TListItem; State: TCustomDrawState;
var DefaultDraw: Boolean);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
Theme: hTheme;
public
{ Public declarations }
end;
var
Form20: TForm20;
implementation
{$R *.dfm}
procedure TForm20.FormCreate(Sender: TObject);
begin
SetWindowTheme(lvRecentFiles.Handle, '
Explorer',
nil);
Theme := OpenThemeData(0, '
ListView');
end;
procedure TForm20.FormDestroy(Sender: TObject);
begin
CloseThemeData(Theme);
end;
procedure TForm20.lvRecentFilesCustomDraw(Sender: TCustomListView;
const ARect: TRect;
var DefaultDraw: Boolean);
//var
// StateId: Integer;
begin
// StateId := LIS_SELECTED; // LIS_SELECTEDNOTFOCUS // LIS_NORMAL
// DrawThemeBackground(
// Theme,
// lvRecentFiles.Canvas.Handle,
// LVP_LISTITEM,
// StateId,
// ARect,
// nil
// );
DefaultDraw := True;
end;
procedure TForm20.lvRecentFilesCustomDrawItem(Sender: TCustomListView;
Item: TListItem; State: TCustomDrawState;
var DefaultDraw: Boolean);
begin
DefaultDraw := True;
end;
procedure TForm20.lvRecentFilesDrawItem(Sender: TCustomListView;
Item: TListItem; Rect: TRect; State: TOwnerDrawState);
var
R: TRect;
S:
string;
begin
S := Item.Caption;
with lvRecentFiles, lvRecentFiles.Canvas
do
begin
if FileExists(S)
then
Font.Color := clWindowText
else
Font.Color := clGrayText
;
R := Classes.Rect(Rect.Left + 6, Rect.Top + 3, Rect.Right, Rect.Bottom - 2);
TextRect(R, S, [tfEndEllipsis]);
end;
end;
end.