Skip to content
This repository was archived by the owner on Feb 13, 2026. It is now read-only.

Commit 9c8ba21

Browse files
author
Merrick Zhang
committed
Add Windows Modern Theme support for all sln projects, applying Windows 11 material styles to window borders and toolbars
1 parent fb801d2 commit 9c8ba21

File tree

2 files changed

+49
-5
lines changed

2 files changed

+49
-5
lines changed

matepath/src/matepath.cpp

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,13 @@ LRESULT MsgCreate(HWND hwnd, WPARAM wParam, LPARAM lParam) noexcept {
860860
GetMenuItemInfo(hmenu, SC_MINIMIZE, FALSE, &mii);
861861
mii.wID = SC_MINIMIZE | 0x02;
862862
SetMenuItemInfo(hmenu, SC_MINIMIZE, FALSE, &mii);
863+
864+
// Enable Windows 11 modern theme support
865+
if (IsAppThemed()) {
866+
// Set window theme to use Windows 11 styles
867+
SetWindowTheme(hwnd, L"Explorer", nullptr);
868+
}
869+
863870
return 0;
864871
}
865872

@@ -871,10 +878,15 @@ LRESULT MsgCreate(HWND hwnd, WPARAM wParam, LPARAM lParam) noexcept {
871878
void CreateBars(HWND hwnd, HINSTANCE hInstance) noexcept {
872879
constexpr DWORD dwToolbarStyle = WS_TOOLBAR | TBSTYLE_FLAT | CCS_ADJUSTABLE;
873880
hwndToolbar = CreateWindowEx(0, TOOLBARCLASSNAME, nullptr, dwToolbarStyle,
874-
0, 0, 0, 0, hwnd, AsPointer<HMENU, ULONG_PTR>(IDC_TOOLBAR), hInstance, nullptr);
881+
0, 0, 0, 0, hwnd, AsPointer<HMENU, ULONG_PTR>(IDC_TOOLBAR), hInstance, nullptr);
875882

876883
SendMessage(hwndToolbar, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
877884

885+
// Enable Windows 11 modern theme for toolbar
886+
if (IsAppThemed()) {
887+
SetWindowTheme(hwndToolbar, L"Explorer", nullptr);
888+
}
889+
878890
bool internalBitmap = false;
879891
const int scale = iAutoScaleToolbar;
880892
#if NP2_ENABLE_HIDPI_IMAGE_RESOURCE
@@ -959,10 +971,20 @@ void CreateBars(HWND hwnd, HINSTANCE hInstance) noexcept {
959971
const DWORD dwStatusbarStyle = bShowStatusbar ? (WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE) : (WS_CHILD | WS_CLIPSIBLINGS);
960972
hwndStatus = CreateStatusWindow(dwStatusbarStyle, nullptr, hwnd, IDC_STATUSBAR);
961973

974+
// Enable Windows 11 modern theme for statusbar
975+
if (IsAppThemed()) {
976+
SetWindowTheme(hwndStatus, L"Explorer", nullptr);
977+
}
978+
962979
// Create ReBar and add Toolbar
963980
const DWORD dwReBarStyle = bShowToolbar ? (WS_REBAR | WS_VISIBLE) : WS_REBAR;
964981
hwndReBar = CreateWindowEx(WS_EX_TOOLWINDOW, REBARCLASSNAME, nullptr, dwReBarStyle,
965-
0, 0, 0, 0, hwnd, AsPointer<HMENU, ULONG_PTR>(IDC_REBAR), hInstance, nullptr);
982+
0, 0, 0, 0, hwnd, AsPointer<HMENU, ULONG_PTR>(IDC_REBAR), hInstance, nullptr);
983+
984+
// Enable Windows 11 modern theme for ReBar
985+
if (IsAppThemed()) {
986+
SetWindowTheme(hwndReBar, L"Explorer", nullptr);
987+
}
966988

967989
REBARINFO rbi;
968990
rbi.cbSize = sizeof(REBARINFO);

src/Notepad4.cpp

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1855,6 +1855,13 @@ LRESULT MsgCreate(HWND hwnd, WPARAM wParam, LPARAM lParam) noexcept {
18551855
mruFile.Init(MRU_KEY_RECENT_FILES, iMaxRecentFiles, flags);
18561856
mruFind.Init(MRU_KEY_RECENT_FIND, MRU_MAXITEMS, MRUFlags_QuoteValue);
18571857
mruReplace.Init(MRU_KEY_RECENT_REPLACE, MRU_MAXITEMS, MRUFlags_QuoteValue);
1858+
1859+
// Enable Windows 11 modern theme support
1860+
if (IsAppThemed()) {
1861+
// Set window theme to use Windows 11 styles
1862+
SetWindowTheme(hwnd, L"Explorer", nullptr);
1863+
}
1864+
18581865
return 0;
18591866
}
18601867

@@ -1864,12 +1871,17 @@ LRESULT MsgCreate(HWND hwnd, WPARAM wParam, LPARAM lParam) noexcept {
18641871
//
18651872
//
18661873
void CreateBars(HWND hwnd, HINSTANCE hInstance) noexcept {
1867-
constexpr DWORD dwToolbarStyle = WS_TOOLBAR;
1874+
constexpr DWORD dwToolbarStyle = WS_TOOLBAR | TBSTYLE_FLAT;
18681875
hwndToolbar = CreateWindowEx(0, TOOLBARCLASSNAME, nullptr, dwToolbarStyle,
1869-
0, 0, 0, 0, hwnd, AsPointer<HMENU, ULONG_PTR>(IDC_TOOLBAR), hInstance, nullptr);
1876+
0, 0, 0, 0, hwnd, AsPointer<HMENU, ULONG_PTR>(IDC_TOOLBAR), hInstance, nullptr);
18701877

18711878
SendMessage(hwndToolbar, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
18721879

1880+
// Enable Windows 11 modern theme for toolbar
1881+
if (IsAppThemed()) {
1882+
SetWindowTheme(hwndToolbar, L"Explorer", nullptr);
1883+
}
1884+
18731885
bool internalBitmap = false;
18741886
const int scale = iAutoScaleToolbar;
18751887
#if NP2_ENABLE_HIDPI_IMAGE_RESOURCE
@@ -1959,10 +1971,20 @@ void CreateBars(HWND hwnd, HINSTANCE hInstance) noexcept {
19591971
const DWORD dwStatusbarStyle = bShowStatusbar ? (WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE) : (WS_CHILD | WS_CLIPSIBLINGS);
19601972
hwndStatus = CreateStatusWindow(dwStatusbarStyle, nullptr, hwnd, IDC_STATUSBAR);
19611973

1974+
// Enable Windows 11 modern theme for statusbar
1975+
if (IsAppThemed()) {
1976+
SetWindowTheme(hwndStatus, L"Explorer", nullptr);
1977+
}
1978+
19621979
// Create ReBar and add Toolbar
19631980
const DWORD dwReBarStyle = bShowToolbar ? (WS_REBAR | WS_VISIBLE) : WS_REBAR;
19641981
hwndReBar = CreateWindowEx(WS_EX_TOOLWINDOW, REBARCLASSNAME, nullptr, dwReBarStyle,
1965-
0, 0, 0, 0, hwnd, AsPointer<HMENU, ULONG_PTR>(IDC_REBAR), hInstance, nullptr);
1982+
0, 0, 0, 0, hwnd, AsPointer<HMENU, ULONG_PTR>(IDC_REBAR), hInstance, nullptr);
1983+
1984+
// Enable Windows 11 modern theme for ReBar
1985+
if (IsAppThemed()) {
1986+
SetWindowTheme(hwndReBar, L"Explorer", nullptr);
1987+
}
19661988

19671989
REBARINFO rbi;
19681990
rbi.cbSize = sizeof(REBARINFO);

0 commit comments

Comments
 (0)