Description
This PR fixes several MSW menu rendering issues observed in dark mode and on Windows 11.
1- It includes changes to make menu breaks render correctly in dark mode (owner-drawn).
2- applies dark-mode-aware menu background colors, adjusts owner-drawn menu item drawing (text color fallbacks).
3- applies Windows 11 DWM window attributes to popup menu windows to get rounded corners and proper border color.
High-level items implemented or touched by this PR:
- Force owner-draw for menu-break items when dark mode is active so they render correctly.
- Use theme-aware colors for popup menu background and menu item text; add fallbacks when dark-theme values are unavailable.
- change popup menu background .
- Update theme handle usage (supply dark-mode theme identifiers where applicable).
- Set DWM attributes (rounded corners and border color) for menu windows on Windows 11+ dynamically.
Changes Proposed
- src/msw/menu.cpp
- Include darkmode and uxtheme private headers.
- When m_doBreak is set and dark mode is active, mark the item owner-drawn.
- On menu creation, when wxMSWDarkMode is active and owner-drawn is used, query theme popup background color.
- src/msw/menuitem.cpp
- Include darkmode header.
- Use dark-mode-aware theme string when creating wxUxThemeHandle).
- Obtain TMT_TEXTCOLOR from theme in dark mode, with fallback to system menu text color if not available.
- src/msw/window.cpp
- Dynamically call DwmSetWindowAttribute to set DWMWA_WINDOW_CORNER_PREFERENCE (rounded corners) and DWMWA_BORDER_COLOR.
- Load dwmapi.dll and DwmSetWindowAttribute with LoadLibrary/GetProcAddress to avoid link dependency.
Motivation and Context
- Dark-mode menus and menu breaks displayed incorrectly with default rendering; forcing owner-draw and using theme colors addresses incorrect backgrounds and text colors in dark themes.
- Windows 11 introduced different menu visuals (rounded corners, border colors). Applying DWM attributes to popup menu windows improves visual consistency for native-looking menus.
- The changes aim to preserve visual correctness across themes and OS versions while avoiding hard dependencies on newer APIs at link time.
How Has This Been Tested?
Screenshots
before
Screenshot.2025-12-24.101158.png (view on web)
after
Screenshot.2025-12-24.100600.png (view on web)
Developer notes and required follow-ups
Address the following soon after merging this PR:
Related issues
Fixes #25577
Fixes #22518
Suggested reviewers
@vadz
You can view, comment on, or merge this pull request online at:
https://github.com/wxWidgets/wxWidgets/pull/26053
Commit Summary
- e2dc406 Fix menu rounded corners in Windows 11 and higher
- a357f52 Set dark mode menu background color and if menu has break Set it OwnerDrawn at darkMode
- 713363d Add DarkMode Theme to OwnerDrawn Menu Items
File Changes
(3 files)
Patch Links:
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.
Message ID: <wxWidgets/wxWidgets/pull/26053@github.com>