Classic Theme Windows: client edge
This commit is contained in:
parent
063e7484ab
commit
f45b3c95f1
1 changed files with 94 additions and 7 deletions
|
@ -2,7 +2,7 @@
|
||||||
// @id classic-theme-windows
|
// @id classic-theme-windows
|
||||||
// @name Classic Theme Windows
|
// @name Classic Theme Windows
|
||||||
// @description Forces Classic Theme on all Windows
|
// @description Forces Classic Theme on all Windows
|
||||||
// @version 0.3
|
// @version 0.4
|
||||||
// @author Travis, Cynosphere
|
// @author Travis, Cynosphere
|
||||||
// @include *
|
// @include *
|
||||||
// @exclude wininit.exe
|
// @exclude wininit.exe
|
||||||
|
@ -13,7 +13,6 @@
|
||||||
// @exclude svchost.exe
|
// @exclude svchost.exe
|
||||||
// @exclude taskhostw.exe
|
// @exclude taskhostw.exe
|
||||||
// @exclude dllhost.exe
|
// @exclude dllhost.exe
|
||||||
// @exclude rundll32.exe
|
|
||||||
// @exclude sihost.exe
|
// @exclude sihost.exe
|
||||||
// @exclude lsass.exe
|
// @exclude lsass.exe
|
||||||
// @exclude C:\Program Files (x86)\Steam\*
|
// @exclude C:\Program Files (x86)\Steam\*
|
||||||
|
@ -40,11 +39,71 @@ Forces Classic Theme on all Windows
|
||||||
*/
|
*/
|
||||||
// ==/WindhawkModReadme==
|
// ==/WindhawkModReadme==
|
||||||
|
|
||||||
|
#include <windhawk_api.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <uxtheme.h>
|
#include <uxtheme.h>
|
||||||
#include <dwmapi.h>
|
#include <dwmapi.h>
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
|
|
||||||
|
// credit to Anixx for this snippet
|
||||||
|
void ClientEdgeFixes(HWND hWnd) {
|
||||||
|
HWND cn = NULL;
|
||||||
|
HWND p = hWnd;
|
||||||
|
wchar_t bufr[256];
|
||||||
|
GetClassName(hWnd, bufr, 256);
|
||||||
|
|
||||||
|
//Mathematica
|
||||||
|
if (lstrcmpW(bufr, L"NotebookFrame") == 0)
|
||||||
|
{
|
||||||
|
p = FindWindowEx(p, NULL, L"NotebookContent", NULL);
|
||||||
|
if(p != NULL)
|
||||||
|
{
|
||||||
|
cn = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Notepad
|
||||||
|
if (lstrcmpW(bufr, L"Notepad") == 0)
|
||||||
|
{
|
||||||
|
p = FindWindowEx(p, NULL, L"Edit", NULL);
|
||||||
|
if(p != NULL)
|
||||||
|
{
|
||||||
|
cn = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Console
|
||||||
|
if (lstrcmpW(bufr, L"ConsoleWindowClass") == 0)
|
||||||
|
{
|
||||||
|
cn = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
// File picker
|
||||||
|
if (lstrcmpW(bufr, L"#32770") == 0)
|
||||||
|
{
|
||||||
|
p = FindWindowEx(p, NULL, L"SHELLDLL_DefView", NULL);
|
||||||
|
if(p != NULL)
|
||||||
|
{
|
||||||
|
p = FindWindowEx(p, NULL, L"SysListView32", NULL);
|
||||||
|
if(p != NULL)
|
||||||
|
{
|
||||||
|
cn = p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(cn != NULL)
|
||||||
|
{
|
||||||
|
SetWindowLongPtrW(cn, GWL_EXSTYLE, GetWindowLongPtrW(cn, GWL_EXSTYLE) | WS_EX_CLIENTEDGE);
|
||||||
|
RECT rect;
|
||||||
|
GetWindowRect(cn, &rect);
|
||||||
|
SetWindowPos(cn, NULL, NULL, NULL, rect.right - rect.left + 1, rect.bottom - rect.top, SWP_NOMOVE | SWP_NOZORDER | SWP_DEFERERASE);
|
||||||
|
SetWindowPos(cn, NULL, NULL, NULL, rect.right - rect.left, rect.bottom - rect.top, SWP_NOMOVE | SWP_NOZORDER | SWP_DEFERERASE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// BasicThemer2 reimplementation to render classic titlebars
|
// BasicThemer2 reimplementation to render classic titlebars
|
||||||
static const int DisableDWM = DWMNCRP_DISABLED;
|
static const int DisableDWM = DWMNCRP_DISABLED;
|
||||||
static const int EnableDWM = DWMNCRP_ENABLED;
|
static const int EnableDWM = DWMNCRP_ENABLED;
|
||||||
|
@ -69,8 +128,10 @@ BOOL CALLBACK DisableDWMForAll(HWND hWnd, LPARAM lParam) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ClientEdgeFixes(hWnd);
|
||||||
|
|
||||||
if (IsWindow(hWnd)) {
|
if (IsWindow(hWnd)) {
|
||||||
Wh_Log(L"[Init] Window found: %08X", (DWORD)(ULONG_PTR)hWnd);
|
//Wh_Log(L"[Init] Window found: %08X", (DWORD)(ULONG_PTR)hWnd);
|
||||||
|
|
||||||
if (!g_uiThreadId) {
|
if (!g_uiThreadId) {
|
||||||
g_uiThreadId = dwThreadId;
|
g_uiThreadId = dwThreadId;
|
||||||
|
@ -94,7 +155,7 @@ BOOL CALLBACK EnableDWMForAll(HWND hWnd, LPARAM lParam) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsWindow(hWnd)) {
|
if (IsWindow(hWnd)) {
|
||||||
Wh_Log(L"[Cleanup] Window found: %08X", (DWORD)(ULONG_PTR)hWnd);
|
//Wh_Log(L"[Cleanup] Window found: %08X", (DWORD)(ULONG_PTR)hWnd);
|
||||||
|
|
||||||
if (!g_uiThreadId) {
|
if (!g_uiThreadId) {
|
||||||
g_uiThreadId = dwThreadId;
|
g_uiThreadId = dwThreadId;
|
||||||
|
@ -120,7 +181,7 @@ HWND WINAPI CreateWindowExW_Hook(DWORD dwExStyle,LPCWSTR lpClassName,LPCWSTR lpW
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsWindow(hWnd)) {
|
if (IsWindow(hWnd)) {
|
||||||
Wh_Log(L"[CreateWindowExW] Window created: %08X", (DWORD)(ULONG_PTR)hWnd);
|
//Wh_Log(L"[CreateWindowExW] Window created: %08X", (DWORD)(ULONG_PTR)hWnd);
|
||||||
|
|
||||||
if (!g_uiThreadId) {
|
if (!g_uiThreadId) {
|
||||||
g_uiThreadId = GetCurrentThreadId();
|
g_uiThreadId = GetCurrentThreadId();
|
||||||
|
@ -146,7 +207,7 @@ HWND WINAPI CreateWindowExA_Hook(DWORD dwExStyle,LPCSTR lpClassName,LPCSTR lpWin
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsWindow(hWnd)) {
|
if (IsWindow(hWnd)) {
|
||||||
Wh_Log(L"[CreateWindowExA] Window created: %08X", (DWORD)(ULONG_PTR)hWnd);
|
//Wh_Log(L"[CreateWindowExA] Window created: %08X", (DWORD)(ULONG_PTR)hWnd);
|
||||||
|
|
||||||
if (!g_uiThreadId) {
|
if (!g_uiThreadId) {
|
||||||
g_uiThreadId = GetCurrentThreadId();
|
g_uiThreadId = GetCurrentThreadId();
|
||||||
|
@ -172,6 +233,30 @@ HWND WINAPI SHCreateWorkerWindowHook(WNDPROC wndProc, HWND hWndParent, DWORD dwE
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using ShowWindow_t = decltype(&ShowWindow);
|
||||||
|
ShowWindow_t pOriginalShowWindow;
|
||||||
|
WINBOOL WINAPI ShowWindowHook(HWND hWnd,int nCmdShow)
|
||||||
|
{
|
||||||
|
bool ret = pOriginalShowWindow(hWnd, nCmdShow);
|
||||||
|
|
||||||
|
if (g_uiThreadId && g_uiThreadId != GetCurrentThreadId()) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsWindow(hWnd)) {
|
||||||
|
//Wh_Log(L"[ShowWindowHook] Window created: %08X", (DWORD)(ULONG_PTR)hWnd);
|
||||||
|
|
||||||
|
if (!g_uiThreadId) {
|
||||||
|
g_uiThreadId = GetCurrentThreadId();
|
||||||
|
}
|
||||||
|
|
||||||
|
DisableDWMForHwnd(hWnd);
|
||||||
|
//EnumWindows(DisableDWMForAll, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
// File picker
|
// File picker
|
||||||
template<class S>
|
template<class S>
|
||||||
CLSID CreateGUID(const S& hexString)
|
CLSID CreateGUID(const S& hexString)
|
||||||
|
@ -211,11 +296,13 @@ BOOL Wh_ModInit() {
|
||||||
Wh_SetFunctionHook((void*)CreateWindowExA,
|
Wh_SetFunctionHook((void*)CreateWindowExA,
|
||||||
(void*)CreateWindowExA_Hook,
|
(void*)CreateWindowExA_Hook,
|
||||||
(void**)&CreateWindowExA_Orig);
|
(void**)&CreateWindowExA_Orig);
|
||||||
|
|
||||||
HMODULE hShcore = GetModuleHandle(L"shcore.dll");
|
HMODULE hShcore = GetModuleHandle(L"shcore.dll");
|
||||||
void* origFunc = (void*)GetProcAddress(hShcore, (LPCSTR)188);
|
void* origFunc = (void*)GetProcAddress(hShcore, (LPCSTR)188);
|
||||||
Wh_SetFunctionHook(origFunc, (void*)SHCreateWorkerWindowHook, (void**)&pOriginalSHCreateWorkerWindow);
|
Wh_SetFunctionHook(origFunc, (void*)SHCreateWorkerWindowHook, (void**)&pOriginalSHCreateWorkerWindow);
|
||||||
|
|
||||||
|
Wh_SetFunctionHook((void*)ShowWindow, (void*)ShowWindowHook, (void**)&pOriginalShowWindow);
|
||||||
|
|
||||||
// Iterate every window to enable BasicThemer
|
// Iterate every window to enable BasicThemer
|
||||||
EnumWindows(DisableDWMForAll, 0);
|
EnumWindows(DisableDWMForAll, 0);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue