Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notepad Clientedge 1.0.0 #353

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions mods/notepad-clientedge.wh.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// ==WindhawkMod==
// @id notepad-clientedge
// @name Notepad Clientedge
// @description Applies client edge to newer versions of Notepad
// @version 1.0.0
// @author aubymori
// @github https://github.com/aubymori
// @include notepad.exe
// ==/WindhawkMod==

// ==WindhawkModReadme==
/*
# Notepad Clientedge
In a Windows 10 update, the `WS_EX_CLIENTEDGE` style was removed from Notepad's
edit control, resulting in an inaccurate appearance on classic theme or other
themes of old Windows versions. This mod adds that back.

**Before**:

![Before](https://raw.githubusercontent.com/aubymori/images/main/notepad-clientedge-before.png)

**After**:

![After](https://raw.githubusercontent.com/aubymori/images/main/notepad-clientedge-after.png)
*/
// ==/WindhawkModReadme==

using CreateWindowExW_t = decltype(&CreateWindowExW);
CreateWindowExW_t CreateWindowExW_orig;
HWND WINAPI CreateWindowExW_hook(
DWORD dwExStyle,
LPCWSTR lpClassName,
LPCWSTR lpWindowName,
DWORD dwStyle,
int X,
int Y,
int nWidth,
int nHeight,
HWND hWndParent,
HMENU hMenu,
HINSTANCE hInstance,
LPVOID lpParam
)
{
if (hWndParent != NULL
&& ((ULONG_PTR)lpClassName & ~(ULONG_PTR)0xffff) != 0
&& !wcsicmp(lpClassName, L"EDIT"))
{
WCHAR szParentClass[256];
if (GetClassNameW(hWndParent, szParentClass, 256))
{
if (!wcsicmp(szParentClass, L"Notepad"))
{
dwExStyle |= WS_EX_CLIENTEDGE;
}
}
}

return CreateWindowExW_orig(
dwExStyle,
lpClassName,
lpWindowName,
dwStyle,
X,
Y,
nWidth,
nHeight,
hWndParent,
hMenu,
hInstance,
lpParam
);
}

BOOL Wh_ModInit(void)
{
if (!Wh_SetFunctionHook(
(void *)CreateWindowExW,
(void *)CreateWindowExW_hook,
(void **)&CreateWindowExW_orig
))
{
Wh_Log(L"Failed to hook CreateWindowExW");
return FALSE;
}

return TRUE;
}
Loading