When an owner draw menu item is added, the menu loses its native look (i.e. rounded corners). It can be reproduced using the menu sample. Replace
menu.Append(Menu_PopupChoice + n, choices[n]);
in samples\menu\menu.cpp with
wxMenuItem *item = wxMenuItem::New(nullptr, Menu_PopupChoice + n, choices[n]);
item->SetTextColour(0x0000AA);
menu.Append(item);
Platform and version information
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
I don't think it's a bug, the menu seems to switch to an older look if it has owner-drawn items. And unless there is some new API to change the colour of the menu items in Windows 11 that I don't know about, making them owner-drawn is the only way to do it.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
The color was simply used as an example, the main issue here is that owner draw is unusable on Windows 11, since it kills the native look. Maybe there's some flag that tells Windows not to switch to the older look, or a new API to draw the rounded frame. Probably worth investigating.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
I wouldn't call this "unusable" but it clearly doesn't look great. But if the choice is between this and not using the user-specified colours at all, I don't know what's better.
Investigations/suggestions would be welcome, of course, but for now the only thing to do is to avoid changing colours in the first place.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
I could not find anything regarding menus in the docs, e.g. here: https://docs.microsoft.com/en-us/windows/apps/desktop/modernize/apply-rounded-corners
I do not actually use Windows 11 so I have only few programs to look at but FWIW, both latest MSVS 2022 and CMake-GUI versions do not have rounded menus there either.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Thanks for checking! I'm especially amazed by
By design, apps are not rounded when maximized, snapped, running in a Virtual Machine (VM) [...]
part, do they do this intentionally to make testing more fun?
But they do cover the case of the menus in the Example 4, so apparently we might be able to call DwmSetWindowAttribute(DWMWA_WINDOW_CORNER_PREFERENCE, DWMWCP_ROUNDSMALL) for them, if we just find the correct HWND to apply this to.
I'm not going to be able to do/test this myself however, no way I'm installing Windows 11 anywhere other than in a VM...
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Thanks for checking! I'm especially amazed by
By design, apps are not rounded when maximized, snapped, running in a Virtual Machine (VM) [...]
part, do they do this intentionally to make testing more fun?
I do not understand that, all I have is a VirtualBox VM and I do see the rounded corners everywhere expected.
But they do cover the case of the menus in the Example 4, so apparently we might be able to call
DwmSetWindowAttribute(DWMWA_WINDOW_CORNER_PREFERENCE, DWMWCP_ROUNDSMALL)for them, if we just find the correctHWNDto apply this to.
I tried doing this
diff --git a/samples/ownerdrw/ownerdrw.cpp b/samples/ownerdrw/ownerdrw.cpp index d7f153b506..72d95d3167 100644 --- a/samples/ownerdrw/ownerdrw.cpp +++ b/samples/ownerdrw/ownerdrw.cpp @@ -24,6 +24,8 @@ #include "wx/menuitem.h" #include "wx/checklst.h" +#include <dwmapi.h> + // Define a new application type class OwnerDrawnApp: public wxApp { @@ -97,6 +99,10 @@ bool OwnerDrawnApp::OnInit(void) // create the menu bar for the main frame void OwnerDrawnFrame::InitMenu() { + DWM_WINDOW_CORNER_PREFERENCE preference = DWMWCP_ROUNDSMALL; + DwmSetWindowAttribute(GetHWND(), DWMWA_WINDOW_CORNER_PREFERENCE, &preference, sizeof(preference)); + + // Make a menubar wxMenuItem *pItem; wxMenu *file_menu = new wxMenu;
but it does not seem to help, so I may be doing something wrong. However, as I wrote before, I see the rounded and unrounded menus in the same menubar in those two unmodified samples, so it would be odd it if doing this at the frame level would have helped...
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
EDIT It also seems that
DwmSetWindowAttribute()has no effect on menus whatsoever. Calling it withDWMWCP_DONOTROUNDmakes the frame itself not rounded, yet its non-custom-drawn menu in the menubar and the native window menu remain rounded. I don't think I am using a wrongHWNDhere
Use the hwnd of the wxmenu not the window. A menu is a window in win32.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Use the hwnd of the wxmenu not the window. A menu is a window in win32.
@marekr, I have been using Windows API for almost three decades but this is the first time I hear this. I have always thought HWND and HMENU point to different Windows internal structs?
The above-mentioned Example 4 also uses window's HWND to apply rounded corners to a menu.
Either way, I tried calling ::DwmSetWindowAttribute() with a HMENU cast to HWND. The function always returned E_HANDLE for HMENUs obtained from menu_bar as well as from drawn_menu, as opposed to E_SUCCESS returned when using OwnerDrawnFrame's HWND.
Or did I misunderstand and you meant doing something else?
I, being the realist, believe it is just another example of Microsoft not caring about Windows API. It started with not updating DrawTheme() function family and peaked in not providing the dark mode, so things like this are not surprising at all.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()