+ chg: first part of DarkMode Theme for MiniPath

This commit is contained in:
Rainer Kottenhoff 2020-09-19 22:15:20 +02:00
parent 0c2629507e
commit 32b6b7b656
12 changed files with 285 additions and 81 deletions

View File

@ -86,7 +86,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_WINDOWS;_M_IX86;_DEBUG;DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>D_NP3_WIN10_DARK_MODE;WIN32;_WINDOWS;_M_IX86;_DEBUG;DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderOutputFile>
@ -143,7 +143,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<PreprocessorDefinitions>WIN32;_WINDOWS;_M_IX86;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>D_NP3_WIN10_DARK_MODE;WIN32;_WINDOWS;_M_IX86;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
@ -220,7 +220,7 @@
<PrecompiledHeaderOutputFile>
</PrecompiledHeaderOutputFile>
<PrecompiledHeaderFile />
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>D_NP3_WIN10_DARK_MODE;WIN32;_WINDOWS;_DEBUG;DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
<FloatingPointModel>Fast</FloatingPointModel>
@ -256,7 +256,7 @@
<PrecompiledHeaderOutputFile>
</PrecompiledHeaderOutputFile>
<PrecompiledHeaderFile />
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>D_NP3_WIN10_DARK_MODE;WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
<WholeProgramOptimization>true</WholeProgramOptimization>
@ -282,6 +282,7 @@
</ManifestResourceCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\src\DarkMode\DarkMode.cpp" />
<ClCompile Include="src\Config.cpp" />
<ClCompile Include="src\Dialogs.c" />
<ClCompile Include="src\Dlapi.c" />
@ -291,6 +292,7 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\src\Config\SimpleIni.h" />
<ClInclude Include="..\src\DarkMode\DarkMode.h" />
<ClInclude Include="language\common_res.h" />
<ClInclude Include="src\Config.h" />
<ClInclude Include="src\Dialogs.h" />

View File

@ -37,6 +37,9 @@
<ClCompile Include="src\Config.cpp">
<Filter>C/C++ Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\DarkMode\DarkMode.cpp">
<Filter>C/C++ Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\Dialogs.h">
@ -69,6 +72,9 @@
<ClInclude Include="..\src\Config\SimpleIni.h">
<Filter>H Source Files</Filter>
</ClInclude>
<ClInclude Include="..\src\DarkMode\DarkMode.h">
<Filter>H Source Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="res\Hover.cur">

View File

@ -30,6 +30,7 @@
#include "minipath.h"
#include "dlapi.h"
#include "config.h"
#include "..\..\src\DarkMode\DarkMode.h"
#include "dialogs.h"
#include "resource.h"
@ -1021,7 +1022,6 @@ INT_PTR CALLBACK ItemsPageProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
}
case WM_CTLCOLORSTATIC:
if (!m_bDefCrNoFilt && GetDlgCtrlID((HWND)lParam) == IDC_COLOR_SAMP1)
@ -1263,22 +1263,20 @@ INT_PTR OptionsPropSheet(HWND hwnd,HINSTANCE hInstance)
ListView_SetExtendedListViewStyleEx(hwndDirList,
LVS_EX_FULLROWSELECT,
LVS_EX_FULLROWSELECT);
if (IsVista())
SetTheme(hwndDirList,L"Explorer");
SetExplorerTheme(hwndDirList);
}
else {
ListView_SetExtendedListViewStyleEx(hwndDirList,
LVS_EX_FULLROWSELECT,0);
if (IsVista())
SetTheme(hwndDirList,L"Listview");
SetTheme(hwndDirList,L"Listview");
}
if (lstrcmp(Settings.tchFilter,L"*.*") || Settings.bNegFilter) {
ListView_SetTextColor(hwndDirList,(Settings.bDefCrFilter) ? GetSysColor(COLOR_WINDOWTEXT) : Settings.crFilter);
ListView_SetTextColor(hwndDirList,(Settings.bDefCrFilter) ? GetModeTextColor(IsDarkModeSupported()) : Settings.crFilter);
ListView_RedrawItems(hwndDirList,0,ListView_GetItemCount(hwndDirList)-1);
}
else {
ListView_SetTextColor(hwndDirList,(Settings.bDefCrNoFilt) ? GetSysColor(COLOR_WINDOWTEXT) : Settings.crNoFilt);
ListView_SetTextColor(hwndDirList,(Settings.bDefCrNoFilt) ? GetModeTextColor(IsDarkModeSupported()) : Settings.crNoFilt);
ListView_RedrawItems(hwndDirList,0,ListView_GetItemCount(hwndDirList)-1);
}

View File

@ -13,6 +13,7 @@
* *
* *
*******************************************************************************/
#include <uxtheme.h>
BOOL GetDirectory(HWND,int,LPWSTR,LPCWSTR,BOOL);
BOOL GetDirectory2(HWND,int,LPWSTR,int);
@ -48,4 +49,13 @@ int ErrorMessage(int, UINT, ...);
DWORD MsgBoxLastError(LPCWSTR lpszMessage, DWORD dwErrID);
DWORD DbgMsgBoxLastError(LPCWSTR lpszMessage, DWORD dwErrID);
#define SetExplorerTheme(hwnd) SetWindowTheme((hwnd), L"Explorer", NULL)
inline void InitWindowCommon(HWND hwnd, BOOL bSetExplorerTheme) {
if (bSetExplorerTheme) { SetExplorerTheme(hwnd); }
else { SetWindowTheme(hwnd, L"", L""); }
//SetWindowLayoutRTL(hwnd, Settings.DialogsLayoutRTL);
}
// End of Dialogs.h

View File

@ -1084,7 +1084,6 @@ BOOL DirList_MatchFilter(LPSHELLFOLDER lpsf,LPCITEMIDLIST pidl,PDL_FILTER pdlf)
//
typedef struct tagDC_ITEMDATA
{
LPITEMIDLIST pidl;
LPSHELLFOLDER lpsf;
@ -1105,6 +1104,7 @@ BOOL DriveBox_Init(HWND hwnd)
hil = (HIMAGELIST)SHGetFileInfo(L"C:\\",0,&shfi,sizeof(SHFILEINFO),
SHGFI_SMALLICON | SHGFI_SYSICONINDEX);
SendMessage(hwnd,CBEM_SETWINDOWTHEME, 0, (LPARAM)L"Explorer");
SendMessage(hwnd,CBEM_SETIMAGELIST,0,(LPARAM)hil);
SendMessage(hwnd,CBEM_SETEXTENDEDSTYLE,CBES_EX_NOSIZELIMIT,CBES_EX_NOSIZELIMIT);

View File

@ -514,10 +514,8 @@ void SetWindowTransparentMode(HWND hwnd, BOOL bTransparentMode, int iOpacityLeve
//
BOOL StatusSetText(HWND hwnd,UINT nPart,LPCWSTR lpszText)
{
UINT uFlags = (nPart == 255) ? nPart|SBT_NOBORDERS : nPart;
UINT const uFlags = SBT_OWNERDRAW | nPart;
return (BOOL)SendMessage(hwnd,SB_SETTEXT,uFlags,(LPARAM)lpszText);
}

View File

@ -14,6 +14,8 @@
* *
*******************************************************************************/
#include <VersionHelpers.h>
extern HINSTANCE g_hInstance;
extern HMODULE g_hLngResContainer;
extern UINT16 g_uWinVer;
@ -34,11 +36,6 @@ inline BOOL IsKeyDown(int key) { return (((GetKeyState(key) >> 8) & 0xff) != 0);
void BeginWaitCursor();
void EndWaitCursor();
#define Is2k() (g_uWinVer >= 0x0500)
#define IsXP() (g_uWinVer >= 0x0501)
#define IsVista() (g_uWinVer >= 0x0600)
#define IsW7() (g_uWinVer >= 0x0601)
BOOL ExeNameFromWnd(HWND,LPWSTR,int);
//BOOL Is32bitExe(LPCWSTR);
BOOL PrivateIsAppThemed();
@ -217,4 +214,51 @@ BOOL GetDoAnimateMinimize(VOID);
VOID MinimizeWndToTray(HWND hWnd);
VOID RestoreWndFromTray(HWND hWnd);
#define rgbDarkBkgColorRef (RGB(0x1F, 0x1F, 0x1F))
#define rgbDarkBtnFcColorRef (RGB(0x33, 0x33, 0x33))
#define rgbDarkTxtColorRef (RGB(0xEF, 0xEF, 0xEF))
inline int SetModeBkColor(const HDC hdc, const BOOL bDarkMode) {
return SetBkColor(hdc, bDarkMode ? rgbDarkBkgColorRef : GetSysColor(COLOR_WINDOW));
}
inline int SetModeBtnFaceColor(const HDC hdc, const BOOL bDarkMode) {
return SetBkColor(hdc, bDarkMode ? rgbDarkBtnFcColorRef : GetSysColor(COLOR_BTNFACE));
}
inline COLORREF GetModeBkColor(const BOOL bDarkMode) {
return bDarkMode ? rgbDarkBkgColorRef : (COLORREF)GetSysColor(COLOR_WINDOW);
}
inline COLORREF GetModeBtnfaceColor(const BOOL bDarkMode) {
return bDarkMode ? rgbDarkBtnFcColorRef : (COLORREF)GetSysColor(COLOR_BTNFACE);
}
inline int SetModeTextColor(const HDC hdc, const BOOL bDarkMode) {
return SetTextColor(hdc, bDarkMode ? rgbDarkTxtColorRef : GetSysColor(COLOR_BTNTEXT));
}
inline COLORREF GetModeTextColor(const BOOL bDarkMode) {
return bDarkMode ? rgbDarkTxtColorRef : (COLORREF)GetSysColor(COLOR_BTNTEXT);
}
extern HBRUSH g_hbrDarkModeBkgBrush;
extern HBRUSH g_hbrDarkModeBtnFcBrush;
#ifdef D_NP3_WIN10_DARK_MODE
inline INT_PTR SetDarkModeCtlColors(const HDC hdc) {
SetBkColor(hdc, rgbDarkBkgColorRef); // (!) non-button static controls
SetTextColor(hdc, rgbDarkTxtColorRef);
//~RECT rc;
//~GetWindowRect(WindowFromDC(hdc), &rc);
//~DrawEdge(hdc, &rc, EDGE_RAISED, BF_FLAT | BF_MONO);
return (INT_PTR)g_hbrDarkModeBkgBrush;
}
#endif
/// End of Helpers.h \\\

View File

@ -28,6 +28,7 @@
#include "dlapi.h"
#include "dialogs.h"
#include "config.h"
#include "..\..\src\DarkMode\DarkMode.h"
#include "minipath.h"
#include "resource.h"
@ -46,6 +47,8 @@ HICON g_hDlgIconSmall = NULL;
WCHAR g_tchPrefLngLocName[LOCALE_NAME_MAX_LENGTH + 1];
LANGID g_iPrefLANGID;
HBRUSH g_hbrDarkModeBkgBrush = NULL;
HBRUSH g_hbrDarkModeBtnFcBrush = NULL;
/******************************************************************************
*
@ -262,6 +265,7 @@ int WINAPI wWinMain(HINSTANCE hInstance,HINSTANCE hPrevInst,LPWSTR lpCmdLine,int
SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX);
// Command Line, Ini File and Flags
InitDarkMode();
InitDefaultSettings();
ParseCommandLine();
FindIniFile();
@ -286,6 +290,13 @@ int WINAPI wWinMain(HINSTANCE hInstance,HINSTANCE hPrevInst,LPWSTR lpCmdLine,int
// Load Settings
LoadSettings();
g_hbrDarkModeBkgBrush = CreateSolidBrush(GetModeBkColor(IsDarkModeSupported()));
g_hbrDarkModeBtnFcBrush = CreateSolidBrush(GetModeBtnfaceColor(IsDarkModeSupported()));
#ifdef D_NP3_WIN10_DARK_MODE
SetDarkMode(IsDarkModeSupported() /* && Settings.WinThemeDarkMode*/); // settings
#endif
// ----------------------------------------------------
// MultiLingual
//
@ -610,6 +621,14 @@ LRESULT CALLBACK MainWndProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
case WM_CREATE:
{
#ifdef D_NP3_WIN10_DARK_MODE
if (IsDarkModeSupported()) {
AllowDarkModeForWindow(hwnd, CheckDarkModeEnabled());
RefreshTitleBarThemeColor(hwnd);
}
#endif
// Init directory watching
// iAutoRefreshRate is in 1/10 sec
int iAutoRefreshRate = IniFileGetInt(g_wchIniFile, L"Settings2", L"AutoRefreshRate", 30);
@ -654,24 +673,38 @@ LRESULT CALLBACK MainWndProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
PostQuitMessage(0);
break;
case WM_DRAWITEM:
return MsgDrawItem(hwnd, wParam, lParam);
CASE_WM_CTLCOLOR_SET:
if (UseDarkMode()) {
return SetDarkModeCtlColors((HDC)wParam);
}
break;
case WM_SETTINGCHANGE:
if (IsDarkModeSupported() && IsColorSchemeChangeMessage(lParam)) {
SendMessage(hwnd, WM_THEMECHANGED, 0, 0);
}
break;
// Reinitialize theme-dependent values and resize windows
case WM_THEMECHANGED:
MsgThemeChanged(hwnd,wParam,lParam);
break;
// update colors of DirList manually
case WM_SYSCOLORCHANGE:
{
LRESULT lret = DefWindowProc(hwnd,umsg,wParam,lParam);
if (lstrcmp(Settings.tchFilter,L"*.*") || Settings.bNegFilter) {
ListView_SetTextColor(hwndDirList,(Settings.bDefCrFilter) ? GetSysColor(COLOR_WINDOWTEXT) : Settings.crFilter);
ListView_SetTextColor(hwndDirList,(Settings.bDefCrFilter) ? GetModeTextColor(IsDarkModeSupported()) : Settings.crFilter);
ListView_RedrawItems(hwndDirList,0,ListView_GetItemCount(hwndDirList)-1);
}
else {
ListView_SetTextColor(hwndDirList,(Settings.bDefCrNoFilt) ? GetSysColor(COLOR_WINDOWTEXT) : Settings.crNoFilt);
ListView_SetTextColor(hwndDirList,(Settings.bDefCrNoFilt) ? GetModeTextColor(IsDarkModeSupported()) : Settings.crNoFilt);
ListView_RedrawItems(hwndDirList,0,ListView_GetItemCount(hwndDirList)-1);
}
@ -955,6 +988,11 @@ LRESULT MsgCreate(HWND hwnd,WPARAM wParam,LPARAM lParam)
MENUITEMINFO mii;
HINSTANCE hInstance = ((LPCREATESTRUCT)lParam)->hInstance;
// Create Toolbar and Statusbar
CreateBars(hwnd, hInstance);
DWORD dwDriveBoxStyle = WS_DRIVEBOX;
hwndDirList = CreateWindowEx(
@ -968,11 +1006,20 @@ LRESULT MsgCreate(HWND hwnd,WPARAM wParam,LPARAM lParam)
hInstance,
NULL);
if (IsVista() && PrivateIsAppThemed()) {
if (PrivateIsAppThemed()) {
SetWindowLongPtr(hwndDirList,GWL_EXSTYLE,GetWindowLongPtr(hwndDirList,GWL_EXSTYLE) & ~WS_EX_CLIENTEDGE);
SetWindowPos(hwndDirList,NULL,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED);
}
// Window Initialization
InitWindowCommon(hwndDirList, TRUE);
#ifdef D_NP3_WIN10_DARK_MODE
if (IsDarkModeSupported()) {
AllowDarkModeForWindow(hwndDirList, CheckDarkModeEnabled());
}
#endif
if (Settings.bShowDriveBox)
dwDriveBoxStyle |= WS_VISIBLE;
@ -987,16 +1034,23 @@ LRESULT MsgCreate(HWND hwnd,WPARAM wParam,LPARAM lParam)
hInstance,
NULL);
// Create Toolbar and Statusbar
CreateBars(hwnd,hInstance);
// Window Initialization
InitWindowCommon(hwndDriveBox, TRUE);
#ifdef D_NP3_WIN10_DARK_MODE
if (IsDarkModeSupported()) {
AllowDarkModeForWindow(hwndDriveBox, CheckDarkModeEnabled());
}
#endif
// DriveBox
DriveBox_Init(hwndDriveBox);
SendMessage(hwndDriveBox,CB_SETEXTENDEDUI,TRUE,0);
// DirList
InitListView(hwndDirList);
ListView_InsertColumn(hwndDirList, 0, &lvc);
ListView_SetExtendedListViewStyle(hwndDirList,LVS_EX_DOUBLEBUFFER|LVS_EX_LABELTIP);
ListView_InsertColumn(hwndDirList,0,&lvc);
DirList_Init(hwndDirList,NULL);
if (Settings.bTrackSelect)
ListView_SetExtendedListViewStyleEx(hwndDirList,
@ -1006,16 +1060,17 @@ LRESULT MsgCreate(HWND hwnd,WPARAM wParam,LPARAM lParam)
ListView_SetExtendedListViewStyleEx(hwndDirList,
LVS_EX_FULLROWSELECT,
LVS_EX_FULLROWSELECT);
if (IsVista())
SetTheme(hwndDirList,L"Explorer");
}
ListView_SetHoverTime(hwndDirList,10);
// Drag & Drop
DragAcceptFiles(hwnd,TRUE);
// History
History_Init(&g_mHistory);
History_UpdateToolbar(&g_mHistory,hwndToolbar,
IDT_HISTORY_BACK,IDT_HISTORY_FORWARD);
// ToolTip with Current Directory
ZeroMemory(&ti,sizeof(TOOLINFO));
ti.cbSize = sizeof(TOOLINFO);
@ -1084,10 +1139,7 @@ static HBITMAP _LoadBitmapFile(LPCWSTR path)
void CreateBars(HWND hwnd,HINSTANCE hInstance)
{
REBARINFO rbi;
REBARBANDINFO rbBand;
RECT rc;
BITMAP bmp;
HBITMAP hbmp, hbmpCopy = NULL;
HIMAGELIST himl;
@ -1109,6 +1161,15 @@ void CreateBars(HWND hwnd,HINSTANCE hInstance)
hwndToolbar = CreateWindowEx(0,TOOLBARCLASSNAME,NULL,dwToolbarStyle,
0,0,0,0,hwnd,(HMENU)IDC_TOOLBAR,hInstance,NULL);
InitWindowCommon(hwndToolbar, TRUE);
#ifdef D_NP3_WIN10_DARK_MODE
if (IsDarkModeSupported()) {
AllowDarkModeForWindow(hwndToolbar, CheckDarkModeEnabled());
}
#endif
SendMessage(hwndToolbar,TB_BUTTONSTRUCTSIZE,(WPARAM)sizeof(TBBUTTON),0);
// Add normal Toolbar Bitmap
@ -1125,7 +1186,7 @@ void CreateBars(HWND hwnd,HINSTANCE hInstance)
hbmpCopy = CopyImage(hbmp,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION);
}
GetObject(hbmp,sizeof(BITMAP),&bmp);
if (!IsXP()) {
if (!IsWindowsXPOrGreater()) {
BitmapMergeAlpha(hbmp, GetSysColor(COLOR_3DFACE));
}
himl = ImageList_Create(bmp.bmWidth/NUMTOOLBITMAPS,bmp.bmHeight,ILC_COLOR32|ILC_MASK,0,0);
@ -1168,9 +1229,9 @@ void CreateBars(HWND hwnd,HINSTANCE hInstance)
BOOL fProcessed = FALSE;
if (flagToolbarLook == 1)
fProcessed = BitmapAlphaBlend(hbmpCopy,GetSysColor(COLOR_3DFACE),0x60);
else if (flagToolbarLook == 2 || (!IsXP() && flagToolbarLook == 0))
else if (flagToolbarLook == 2 || (!IsWindowsXPOrGreater() && flagToolbarLook == 0))
fProcessed = BitmapGrayScale(hbmpCopy);
if (fProcessed && !IsXP())
if (fProcessed && !IsWindowsXPOrGreater())
BitmapMergeAlpha(hbmpCopy,GetSysColor(COLOR_3DFACE));
if (fProcessed) {
himl = ImageList_Create(bmp.bmWidth/NUMTOOLBITMAPS,bmp.bmHeight,ILC_COLOR32|ILC_MASK,0,0);
@ -1231,25 +1292,58 @@ void CreateBars(HWND hwnd,HINSTANCE hInstance)
if (Settings.bShowStatusbar)
dwStatusbarStyle |= WS_VISIBLE;
hwndStatus = CreateStatusWindow(dwStatusbarStyle,NULL,hwnd,IDC_STATUSBAR);
//~hwndStatus = CreateStatusWindow(dwStatusbarStyle,NULL,hwnd,IDC_STATUSBAR);
hwndStatus = CreateWindowEx(
WS_EX_COMPOSITED, // => double-buffering avoids flickering
STATUSCLASSNAME, // name of status bar class
(PCTSTR)NULL, // no text when first created
dwStatusbarStyle, // creates a visible child window
0, 0, 0, 0, // ignores size and position
hwnd, // handle to parent window
(HMENU)IDC_STATUSBAR, // child window identifier
hInstance, // handle to application instance
NULL); // no window creation data
InitWindowCommon(hwndStatus, TRUE); // (!) themed = true : resize grip
#ifdef D_NP3_WIN10_DARK_MODE
if (IsDarkModeSupported()) {
AllowDarkModeForWindow(hwndStatus, CheckDarkModeEnabled());
}
#endif
// Create ReBar and add Toolbar
hwndReBar = CreateWindowEx(WS_EX_TOOLWINDOW,REBARCLASSNAME,NULL,dwReBarStyle,
0,0,0,0,hwnd,(HMENU)IDC_REBAR,hInstance,NULL);
// Theme = false (!) ~ you cannot change a toolbar's color when a visual style is active
InitWindowCommon(hwndReBar, !(IsWindows10OrGreater() && IsDarkModeSupported()));
#ifdef D_NP3_WIN10_DARK_MODE
if (IsDarkModeSupported()) {
AllowDarkModeForWindow(hwndReBar, CheckDarkModeEnabled());
}
#endif
REBARINFO rbi;
rbi.cbSize = sizeof(REBARINFO);
rbi.fMask = 0;
rbi.himl = (HIMAGELIST)NULL;
SendMessage(hwndReBar,RB_SETBARINFO,0,(LPARAM)&rbi);
REBARBANDINFO rbBand;
rbBand.cbSize = sizeof(REBARBANDINFO);
rbBand.fMask = /*RBBIM_COLORS | RBBIM_TEXT | RBBIM_BACKGROUND | */
rbBand.fMask = RBBIM_COLORS /*| RBBIM_TEXT | RBBIM_BACKGROUND */ |
RBBIM_STYLE | RBBIM_CHILD | RBBIM_CHILDSIZE /*| RBBIM_SIZE*/;
rbBand.fStyle = /*RBBS_CHILDEDGE | *//*RBBS_BREAK |*/ RBBS_FIXEDSIZE /*| RBBS_GRIPPERALWAYS*/;
if (bIsAppThemed)
rbBand.fStyle |= RBBS_CHILDEDGE;
rbBand.hbmBack = NULL;
rbBand.lpText = L"Toolbar";
rbBand.clrFore = GetModeTextColor(UseDarkMode());
rbBand.clrBack = IsWindows10OrGreater() ? GetModeBkColor(UseDarkMode()) : GetModeBtnfaceColor(UseDarkMode());
rbBand.hwndChild = hwndToolbar;
rbBand.cxMinChild = (rc.right - rc.left) * COUNTOF(tbbMainWnd);
rbBand.cyMinChild = (rc.bottom - rc.top) + 2 * rc.top;
@ -1261,8 +1355,66 @@ void CreateBars(HWND hwnd,HINSTANCE hInstance)
cyReBar = rc.bottom - rc.top;
cyReBarFrame = bIsAppThemed ? 0 : 2;
cyDriveBoxFrame = (bIsAppThemed && IsVista()) ? 0 : 2;
cyDriveBoxFrame = (bIsAppThemed && IsWindowsVistaOrGreater()) ? 0 : 2;
}
//=============================================================================
//
// MsgDrawItem() - Handles WM_DRAWITEM (needs SBT_OWNERDRAW)
//
// https://docs.microsoft.com/en-us/windows/win32/controls/status-bars#owner-drawn-status-bars
//
LRESULT MsgDrawItem(HWND hwnd, WPARAM wParam, LPARAM lParam)
{
UNUSED(hwnd);
if (LOWORD(wParam) == IDC_STATUSBAR) // Statusbar SB_SETTEXT caused parent's WM_DRAWITEM message
{
const DRAWITEMSTRUCT* const pDIS = (const DRAWITEMSTRUCT* const)lParam;
HDC const hdc = pDIS->hDC;
RECT const rc = pDIS->rcItem;
//UINT const ctlId = pDIS->CtlID; // child window identifier
//~int const partId = (int)pDIS->itemID ~ don't use
//~int const stateId = (int)pDIS->itemState ~ don't use
//~PAINTSTRUCT ps;
//~BeginPaint(hWndItem, &ps); ~ not needed on WM_DRAWITEM
//~SetModeBkColor(hdc, UseDarkMode());
SetModeBtnFaceColor(hdc, UseDarkMode());
SetModeTextColor(hdc, UseDarkMode());
#ifdef D_NP3_WIN10_DARK_MODE
if (UseDarkMode()) {
// overpaint part frames
HWND const hWndItem = pDIS->hwndItem;
int const bdh = GetSystemMetrics(SM_CYFRAME);
HDC const hdcFrm = GetWindowDC(hWndItem);
RECT rcf = rc;
for (int i = 1; i < bdh; ++i) {
FrameRect(hdcFrm, &rcf, g_hbrDarkModeBtnFcBrush);
rcf.left -= 1;
rcf.top -= 1;
rcf.bottom += 1;
rcf.right += 1;
}
FrameRect(hdcFrm, &rcf, GetSysColorBrush(COLOR_3DDKSHADOW));
ReleaseDC(hWndItem, hdcFrm);
}
#endif
LPCWSTR const text = (LPCWSTR)(pDIS->itemData);
ExtTextOut(hdc, rc.left + 1, rc.top + 1, ETO_OPAQUE | ETO_NUMERICSLOCAL, &rc, text, lstrlen(text), NULL);
//~EndPaint(hWndItem, &ps);
return TRUE;
}
return FALSE;
}
@ -1273,28 +1425,26 @@ void CreateBars(HWND hwnd,HINSTANCE hInstance)
//
void MsgThemeChanged(HWND hwnd,WPARAM wParam,LPARAM lParam)
{
RECT rc;
WCHAR chStatus[255];
HINSTANCE hInstance = (HINSTANCE)(INT_PTR)GetWindowLongPtr(hwnd,GWLP_HINSTANCE);
BOOL bIsAppThemed = PrivateIsAppThemed();
//BOOL const bIsAppThemed = PrivateIsAppThemed();
//if (Settings.bFullRowSelect)
// SetTheme(hwndDirList,L"Explorer");
//else
// SetTheme(hwndDirList,L"Listview");
if (IsVista() && bIsAppThemed) {
SetWindowLongPtr(hwndDirList,GWL_EXSTYLE,GetWindowLongPtr(hwndDirList,GWL_EXSTYLE) & ~WS_EX_CLIENTEDGE);
SetWindowPos(hwndDirList,NULL,0,0,0,0,SWP_NOZORDER|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE);
if (Settings.bFullRowSelect)
SetTheme(hwndDirList,L"Explorer");
else
SetTheme(hwndDirList,L"Listview");
}
else {
SetWindowLongPtr(hwndDirList,GWL_EXSTYLE,WS_EX_CLIENTEDGE|GetWindowLongPtr(hwndDirList,GWL_EXSTYLE));
SetWindowPos(hwndDirList,NULL,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED);
if (bIsAppThemed)
SetTheme(hwndDirList,L"Listview");
if (IsDarkModeSupported())
{
bool const darkModeEnabled = CheckDarkModeEnabled();
AllowDarkModeForWindow(hwnd, darkModeEnabled);
RefreshTitleBarThemeColor(hwnd);
}
SetWindowLongPtr(hwndDirList, GWL_EXSTYLE, GetWindowLongPtr(hwndDirList, GWL_EXSTYLE) & ~WS_EX_CLIENTEDGE);
SetWindowPos(hwndDirList, NULL, 0, 0, 0, 0, SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE);
// recreate toolbar and statusbar
WCHAR chStatus[255] = { 0 };
SendMessage(hwndStatus,SB_GETTEXT,ID_FILEINFO,(LPARAM)chStatus);
// recreate toolbar and statusbar
@ -1305,15 +1455,17 @@ void MsgThemeChanged(HWND hwnd,WPARAM wParam,LPARAM lParam)
DestroyWindow(hwndStatus);
CreateBars(hwnd,hInstance);
RECT rc;
GetClientRect(hwnd,&rc);
SendMessage(hwnd,WM_SIZE,SIZE_RESTORED,MAKELONG(rc.right,rc.bottom));
StatusSetText(hwndStatus,ID_FILEINFO,chStatus);
UpdateWindow(hwnd);
UNUSED(hwnd);
UNUSED(wParam);
UNUSED(lParam);
}
@ -1324,21 +1476,14 @@ void MsgThemeChanged(HWND hwnd,WPARAM wParam,LPARAM lParam)
//
void MsgSize(HWND hwnd,WPARAM wParam,LPARAM lParam)
{
if (wParam == SIZE_MINIMIZED) { return; }
int x = 0;
int y = 0;
int cx = LOWORD(lParam);
int cy = HIWORD(lParam);
RECT rc;
int x,y,cx,cy;
HDWP hdwp;
int aWidth[1];
if (wParam == SIZE_MINIMIZED)
return;
x = 0;
y = 0;
cx = LOWORD(lParam);
cy = HIWORD(lParam);
if (Settings.bShowToolbar)
{
/* SendMessage(hwndToolbar,WM_SIZE,0,0);
@ -1365,10 +1510,9 @@ void MsgSize(HWND hwnd,WPARAM wParam,LPARAM lParam)
cy -= (rc.bottom - rc.top);
}
hdwp = BeginDeferWindowPos(2);
HDWP hdwp = BeginDeferWindowPos(2);
DeferWindowPos(hdwp,hwndDriveBox,NULL,x,y,cx,max(cy,100),
SWP_NOZORDER | SWP_NOACTIVATE);
DeferWindowPos(hdwp,hwndDriveBox,NULL,x,y,cx,max(cy,100),SWP_NOZORDER | SWP_NOACTIVATE);
if (Settings.bShowDriveBox) {
GetWindowRect(hwndDriveBox,&rc);
@ -1376,18 +1520,19 @@ void MsgSize(HWND hwnd,WPARAM wParam,LPARAM lParam)
cy -= (rc.bottom - rc.top) + cyDriveBoxFrame;
}
DeferWindowPos(hdwp,hwndDirList,NULL,x,y,cx,cy,
SWP_NOZORDER | SWP_NOACTIVATE);
DeferWindowPos(hdwp,hwndDirList,NULL,x,y,cx,cy, SWP_NOZORDER | SWP_NOACTIVATE);
EndDeferWindowPos(hdwp);
// Rebuild DirList Columns
ListView_SetColumnWidth(hwndDirList,0,LVSCW_AUTOSIZE_USEHEADER);
GetClientRect(hwndStatus,&rc);
aWidth[0] = -1;
// Statusbar
//GetClientRect(hwndStatus,&rc);
int aWidth[1] = { 0 }; aWidth[0] = -1;
SendMessage(hwndStatus,SB_SETPARTS,COUNTOF(aWidth),(LPARAM)aWidth);
InvalidateRect(hwndStatus,NULL,TRUE);
StatusSetText(hwndStatus, ID_FILEINFO, L"");
UNUSED(hwnd);
}
@ -2810,11 +2955,11 @@ BOOL ChangeDirectory(HWND hwnd,LPCWSTR lpszNewDir,BOOL bUpdateHistory)
SetWindowPathTitle(hwnd, Settings.szCurDir);
if (lstrcmp(Settings.tchFilter,L"*.*") || Settings.bNegFilter) {
ListView_SetTextColor(hwndDirList,(Settings.bDefCrFilter) ? GetSysColor(COLOR_WINDOWTEXT) : Settings.crFilter);
ListView_SetTextColor(hwndDirList,(Settings.bDefCrFilter) ? GetModeTextColor(IsDarkModeSupported()) : Settings.crFilter);
Toolbar_SetButtonImage(hwndToolbar,IDT_VIEW_FILTER,TBFILTERBMP);
}
else {
ListView_SetTextColor(hwndDirList,(Settings.bDefCrNoFilt) ? GetSysColor(COLOR_WINDOWTEXT) : Settings.crNoFilt);
ListView_SetTextColor(hwndDirList,(Settings.bDefCrNoFilt) ? GetModeTextColor(IsDarkModeSupported()) : Settings.crNoFilt);
Toolbar_SetButtonImage(hwndToolbar,IDT_VIEW_FILTER,TBFILTERBMP+1);
}

View File

@ -182,7 +182,7 @@ void MsgSize(HWND,WPARAM,LPARAM);
void MsgInitMenu(HWND,WPARAM,LPARAM);
LRESULT MsgCommand(HWND,WPARAM,LPARAM);
LRESULT MsgNotify(HWND,WPARAM,LPARAM);
LRESULT MsgDrawItem(HWND, WPARAM, LPARAM);
/// End of minipath.h \\\

View File

@ -15,7 +15,6 @@
#include <cstdint>
#include "TypeDefs.h"
#include "DarkMode.h"
#ifdef D_NP3_WIN10_DARK_MODE

View File

@ -2,6 +2,8 @@
#ifdef __cplusplus
extern "C" {
#else
#include <stdbool.h>
#endif
void SetDarkMode(bool bEnableDarkMode);

View File

@ -2951,7 +2951,7 @@ LRESULT MsgSize(HWND hwnd, WPARAM wParam, LPARAM lParam)
//=============================================================================
//
// MsgDrawItem() - Handles WM_DRAWITEM
// MsgDrawItem() - Handles WM_DRAWITEM (needs SBT_OWNERDRAW)
//
// https://docs.microsoft.com/en-us/windows/win32/controls/status-bars#owner-drawn-status-bars
//