Skip to content

Commit

Permalink
Classic Desktop Icons 1.2.0 and 1.2.1 (#337)
Browse files Browse the repository at this point in the history
* Add option to force non-translucent selection rectangle
  • Loading branch information
aubymori authored Oct 5, 2023
1 parent 4a17788 commit a6a0290
Showing 1 changed file with 51 additions and 14 deletions.
65 changes: 51 additions & 14 deletions mods/classic-desktop-icons.wh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// @id classic-desktop-icons
// @name Classic Desktop Icons
// @description Enables the classic selection style on desktop icons.
// @version 1.1.1
// @version 1.2.1
// @author aubymori
// @github https://github.com/aubymori
// @include explorer.exe
Expand Down Expand Up @@ -38,6 +38,9 @@ the desktop color on the items' labels.
- background: false
$name: Desktop color as label background
$description: Renders the desktop color on the labels' backgrounds, like Windows 2000.
- noselect: false
$name: Non-translucent selection rectangle
$description: Force the desktop to use a non-translucent selection rectangle, like Windows XP.
*/
// ==/WindhawkModSettings==

Expand All @@ -47,15 +50,12 @@ the desktop color on the items' labels.
struct
{
BOOL background;
BOOL noselect;
} settings;

HWND hDesktop = NULL;
BOOL bSubclassed = FALSE;

#define LABELBG settings.background \
? GetSysColor(COLOR_BACKGROUND) \
: CLR_NONE

/**
* UpdateDesktop references DesktopSubclassProc
* and vice-versa, so we need to define one before
Expand Down Expand Up @@ -88,9 +88,26 @@ void UpdateDesktop(void)
SendMessageW(hDesktop, WM_THEMECHANGED, 0, 0);

/* Apply the desktop background color */
DWORD dwBgColor = LABELBG;
if (settings.background)
{
SendMessageW(
hDesktop,
LVM_SETTEXTBKCOLOR,
NULL,
GetSysColor(COLOR_BACKGROUND)
);
}

SendMessageW(hDesktop, LVM_SETTEXTBKCOLOR, NULL, (LPARAM)dwBgColor);
/* Force non-translucent selection rectangle */
if (settings.noselect)
{
SendMessageW(
hDesktop,
LVM_SETEXTENDEDLISTVIEWSTYLE,
LVS_EX_DOUBLEBUFFER,
FALSE
);
}

/* Subclass to update label backgrounds (they get removed normally) */
if (!bSubclassed)
Expand Down Expand Up @@ -176,6 +193,7 @@ HWND WINAPI CreateWindowExW_hook(
void LoadSettings(void)
{
settings.background = Wh_GetIntSetting(L"background");
settings.noselect = Wh_GetIntSetting(L"noselect");
}

BOOL Wh_ModInit(void)
Expand All @@ -202,13 +220,32 @@ BOOL Wh_ModInit(void)

void Wh_ModUninit(void)
{
/**
* Theme the desktop icons again, and remove any text
* background that was set
* Also remove the subclass we set
*/
/* Remove subclass*/
WindhawkUtils::RemoveWindowSubclassFromAnyThread(hDesktop, DesktopSubclassProc);
SendMessageW(hDesktop, LVM_SETTEXTBKCOLOR, NULL, CLR_NONE);

/* Remove desktop background color */
if (settings.background)
{
SendMessageW(
hDesktop,
LVM_SETTEXTBKCOLOR,
NULL,
CLR_NONE
);
}

/* Make selection rectangle translucent again */
if (settings.noselect)
{
SendMessageW(
hDesktop,
LVM_SETEXTENDEDLISTVIEWSTYLE,
LVS_EX_DOUBLEBUFFER,
TRUE
);
}

/* Retheme desktop */
SetWindowTheme(hDesktop, L"Desktop", NULL);
Wh_Log(L"Unloaded Classic Desktop Icons");
}
Expand All @@ -217,4 +254,4 @@ BOOL Wh_ModSettingsChanged(BOOL *bReload)
{
*bReload = TRUE;
return TRUE;
}
}

0 comments on commit a6a0290

Please sign in to comment.