|
@@ -174,6 +174,7 @@ type
|
|
|
FOnChangeFocus: TDirViewChangeFocusEvent;
|
|
|
|
|
|
procedure CNNotify(var Message: TWMNotify); message CN_NOTIFY;
|
|
|
+ procedure WMNotify(var Msg: TWMNotify); message WM_NOTIFY;
|
|
|
procedure WMKeyDown(var Message: TWMKeyDown); message WM_KEYDOWN;
|
|
|
procedure WMLButtonDblClk(var Message: TWMLButtonDblClk); message WM_LBUTTONDBLCLK;
|
|
|
procedure WMLButtonUp(var Message: TWMLButtonUp); message WM_LBUTTONUP;
|
|
@@ -318,6 +319,7 @@ type
|
|
|
procedure DoHistoryGo(Index: Integer);
|
|
|
procedure WMSetFocus(var Message: TWMSetFocus); message WM_SETFOCUS;
|
|
|
procedure WMKillFocus(var Message: TWMKillFocus); message WM_KILLFOCUS;
|
|
|
+ procedure WMThemeChanged(var Message: TMessage); message WM_THEMECHANGED;
|
|
|
procedure EnsureSelectionRedrawn;
|
|
|
function HiddenCount: Integer; virtual; abstract;
|
|
|
function FilteredCount: Integer; virtual; abstract;
|
|
@@ -332,6 +334,7 @@ type
|
|
|
procedure Load(DoFocusSomething: Boolean); virtual;
|
|
|
procedure NeedImageLists(Recreate: Boolean);
|
|
|
procedure FreeImageLists;
|
|
|
+ procedure UpdateDarkMode;
|
|
|
procedure DoUpdateStatusBar(Force: Boolean = False);
|
|
|
procedure DoCustomDrawItem(Item: TListItem; Stage: TCustomDrawStage);
|
|
|
property ImageList16: TImageList read FImageList16;
|
|
@@ -537,7 +540,7 @@ var
|
|
|
implementation
|
|
|
|
|
|
uses
|
|
|
- Math, DirViewColProperties, UITypes, Types, OperationWithTimeout;
|
|
|
+ Math, DirViewColProperties, UITypes, Types, OperationWithTimeout, Winapi.UxTheme, Vcl.Themes;
|
|
|
|
|
|
const
|
|
|
Space = ' ';
|
|
@@ -913,6 +916,35 @@ begin
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
+procedure TCustomDirView.WMNotify(var Msg: TWMNotify);
|
|
|
+begin
|
|
|
+ // This all is to make header text white in dark mode
|
|
|
+ if DarkMode and SupportsDarkMode and (FHeaderHandle <> 0) and (Msg.NMHdr^.hWndFrom = FHeaderHandle) then
|
|
|
+ begin
|
|
|
+ if Msg.NMHdr.code = NM_CUSTOMDRAW then
|
|
|
+ begin
|
|
|
+ with PNMLVCustomDraw(Msg.NMHdr)^ do
|
|
|
+ begin
|
|
|
+ if nmcd.dwDrawStage = CDDS_PREPAINT then
|
|
|
+ begin
|
|
|
+ inherited;
|
|
|
+ Msg.Result := Msg.Result or CDRF_NOTIFYITEMDRAW;
|
|
|
+ end
|
|
|
+ else
|
|
|
+ if nmcd.dwDrawStage = CDDS_ITEMPREPAINT then
|
|
|
+ begin
|
|
|
+ SetTextColor(nmcd.hdc, ColorToRGB(Font.Color));
|
|
|
+ Msg.Result := CDRF_DODEFAULT;
|
|
|
+ inherited;
|
|
|
+ end
|
|
|
+ else inherited;
|
|
|
+ end;
|
|
|
+ end
|
|
|
+ else inherited;
|
|
|
+ end
|
|
|
+ else inherited;
|
|
|
+end;
|
|
|
+
|
|
|
procedure TCustomDirView.CNNotify(var Message: TWMNotify);
|
|
|
|
|
|
procedure DrawOverlayImage(DC: HDC; Image: Integer);
|
|
@@ -1180,6 +1212,31 @@ begin
|
|
|
LargeImages := nil;
|
|
|
end;
|
|
|
|
|
|
+procedure TCustomDirView.WMThemeChanged(var Message: TMessage);
|
|
|
+begin
|
|
|
+ if SupportsDarkMode then // To reduce impact
|
|
|
+ begin
|
|
|
+ UpdateDarkMode;
|
|
|
+ RedrawWindow(Handle, nil, 0, RDW_FRAME or RDW_INVALIDATE);
|
|
|
+ end;
|
|
|
+
|
|
|
+ inherited;
|
|
|
+end;
|
|
|
+
|
|
|
+procedure TCustomDirView.UpdateDarkMode;
|
|
|
+begin
|
|
|
+ if SupportsDarkMode then // To reduce impact
|
|
|
+ begin
|
|
|
+ AllowDarkModeForWindow(Self, DarkMode);
|
|
|
+
|
|
|
+ if FHeaderHandle <> 0 then
|
|
|
+ begin
|
|
|
+ AllowDarkModeForWindow(FHeaderHandle, DarkMode);
|
|
|
+ SendMessage(FHeaderHandle, WM_THEMECHANGED, 0, 0);
|
|
|
+ end;
|
|
|
+ end;
|
|
|
+end;
|
|
|
+
|
|
|
procedure TCustomDirView.CreateWnd;
|
|
|
begin
|
|
|
inherited;
|
|
@@ -1188,7 +1245,14 @@ begin
|
|
|
PopupMenu.Autopopup := False;
|
|
|
FDragDropFilesEx.DragDropControl := Self;
|
|
|
|
|
|
- if DarkMode then AllowDarkModeForWindow(Self, DarkMode);
|
|
|
+ if SupportsDarkMode then
|
|
|
+ begin
|
|
|
+ // This enabled dark mode - List view itself supports dark mode somewhat even in the our 'Explorer' theme.
|
|
|
+ // The 'ItemsView' has better dark mode selection color, but on the other hand is does not have dark scrollbars.
|
|
|
+ // win32-darkmode has ugly fix for that (FixDarkScrollBar), which we do not want to employ.
|
|
|
+ SetWindowTheme(FHeaderHandle, 'ItemsView', nil);
|
|
|
+ if DarkMode then UpdateDarkMode;
|
|
|
+ end;
|
|
|
|
|
|
NeedImageLists(False);
|
|
|
end;
|
|
@@ -3254,7 +3318,7 @@ begin
|
|
|
FDarkMode := Value;
|
|
|
// Call only when switching to dark more and when switching back to the light mode.
|
|
|
// But not for initial light mode - To reduce an impact of calling an undocumented function.
|
|
|
- if HandleAllocated then AllowDarkModeForWindow(Self, DarkMode);
|
|
|
+ if HandleAllocated then UpdateDarkMode;
|
|
|
end;
|
|
|
end;
|
|
|
|