WindowsAppSDK icon indicating copy to clipboard operation
WindowsAppSDK copied to clipboard

Proposal: Support theming of user32 controls like the system menu

Open shaheedmalik opened this issue 5 years ago • 47 comments

I noticed this months ago but I didn't know where to put it at the time. So, I kinda forgot about it.

This reddit post reminded me of it. https://www.reddit.com/r/Windows10/comments/hhwn2z/so_when_i_can_expect_the_context_menus_to_have/

If you right click on the title bar in a Win32 and UWP app, the context menu doesn't match the styling of the context menu used in the app. It also does not match the system selected theme.

I have Dark Mode selected. Win32: image

UWP: image

shaheedmalik avatar Jun 29 '20 15:06 shaheedmalik

This should produce a theme aware Xaml Context Menu with WinUI 3 apps - there is no backwards compatible reasons not to

mdtauk avatar Jun 29 '20 21:06 mdtauk

The system menu is a user32 control dating from before the advent of theming. It's possible that "lifting" some of this code would allow us to update it to support theming. That's more than a bugfix, so let me update the title to a proposal that we can consider in the context of Reunion.

stevewri avatar Jun 30 '20 00:06 stevewri

Related to #41. Using the APIs I named there gives you a dark context menu, like currently seen on Explorer: image

sylveon avatar Jul 03 '20 00:07 sylveon

Related to #41. Using the APIs I named there gives you a dark context menu, like currently seen on Explorer: image

Hi. Would you like to share a basic demo code to get a dark context menu? I've seen the other issue, and there are different (undocumented) methods there that I don't know exactly what would be used to accomplish such task.

XamDR avatar Jul 08 '20 18:07 XamDR

See https://github.com/ysc3839/win32-darkmode. There's a bit more setup involved if your app shows more than a context menu, but if it only shows context menus (eg a tray icon only app), only calling SetPreferredAppMode and AllowDarkModeForWindow for the window that hosts the context menus is sufficient.

sylveon avatar Jul 08 '20 18:07 sylveon

sylveon avatar Jul 08 '20 18:07 sylveon

This can be related to #41 where the undocumented dark theme api from uxtheme.dll is being used to enable dark styling on common controls, the ribbon framework, and more.

Also, it'd be great in general if menu bars could be could listen to dark mode, not just the context menus themselves.

AzAgarampur avatar Jul 16 '20 03:07 AzAgarampur

That white menu bar as seen in the last screenshot is horrible too. Doesn't even follow the configured system palette at all (it's supposed to be some grayish color.) Just appears to be hardcoded to be white everywhere currently, for some reason... It does make every classic application look pretty ugly.

kaetemi avatar Jul 18 '20 18:07 kaetemi

#82

Poopooracoocoo avatar Sep 06 '20 07:09 Poopooracoocoo

This is different. The proposal outlined here is about allowing developers more control over the appearance of their app, not changing the default styles.

sylveon avatar Sep 06 '20 07:09 sylveon

i understood. :)

i put that there thinking of the MS Edge case.

Poopooracoocoo avatar Sep 06 '20 07:09 Poopooracoocoo

The whole purpose of this proposal if for apps to have consistency. New apps should not have a context menu that doesn't match the system theme nor should they have one that doesn't match the rest of the OS.

Right clicking on a title bar should present a WinUI 3.0 updated context menu, how Windows 10 looks, not a context menu from Windows Vista.

shaheedmalik avatar Sep 06 '20 12:09 shaheedmalik

How about using these kinds of menus? (This is with the system theme set to light mode.) image

Yes, they aren't being drawn by UWP, but ApplicationFrameHost.exe which creates the UWP Window can draw that instead of the classic one shown below. image

The newer one looks modern and adapts to the current Windows theme too, which is a plus.

AzAgarampur avatar Sep 06 '20 18:09 AzAgarampur

Or even better, replace ALL right click titlebar menus with the one above.

AzAgarampur avatar Sep 06 '20 18:09 AzAgarampur

Or even better, replace ALL right click titlebar menus with the one above.

This literally why I made it.

shaheedmalik avatar Sep 06 '20 19:09 shaheedmalik

@shaheedmalik My bad, I thought you just wanted the legacy Win32 context menus to follow the current theme settings instead of using the updated context menu that explorer uses.

AzAgarampur avatar Sep 06 '20 19:09 AzAgarampur

@shaheedmalik My bad, I thought you just wanted the legacy Win32 context menus to follow the current theme settings instead of using the updated context menu that explorer uses.

I made it because UWP apps don't product an updated context menu. If you go into an app like calculator and right click in the app, it will produce a different context menu than if you right click on the title bar. This problem also happens in Win32 apps, so I posted it in Reunion.

Because the title bar is handled by the shell, I think it's on the shell team to update the context menu to the up to date WinUI 3 context menu, and make it theme aware.

shaheedmalik avatar Sep 06 '20 20:09 shaheedmalik

So the title was misleading me then. This is not supporting theming but just updating the default style.

sylveon avatar Sep 06 '20 22:09 sylveon

So the title was misleading me then.

Yeah, same here.

AzAgarampur avatar Sep 06 '20 22:09 AzAgarampur

I am not sure why the confusion, Steve above stated why he changed the name of the proposal.

shaheedmalik avatar Sep 06 '20 22:09 shaheedmalik

It's funny how much this issue changed from a misunderstanding of how we want this to be fixed. I think that for the most part, this should be about updating the default styles and perhaps in this case, wrapping menus in WinUI menus. Supporting theming for this menu wouldn't benefit any of Microsoft's products too so I'm not sure why they'd choose that approach as it's more work for them.

Poopooracoocoo avatar Sep 07 '20 03:09 Poopooracoocoo

It's funny how much this issue changed from a misunderstanding of how we want this to be fixed. I think that for the most part, this should be about updating the default styles and perhaps in this case, wrapping menus in WinUI menus. Supporting theming for this menu wouldn't benefit any of Microsoft's products too so I'm not sure why they'd choose that approach as it's more work for them.

All that really should be done is update that particular context menu to the new WinUI 3 style and update it so it will reflect the system's color whether light or dark.

At the time I made the proposal, I didn't know that menu was a system menu that was handled by the shell team. I just thought it affected both UWP and Win32.

Others want to say this particular proposal is linked to theirs so theirs would get approved, but it isn't the case at all.

shaheedmalik avatar Sep 07 '20 03:09 shaheedmalik

Others want to say this particular proposal is linked to theirs so theirs would get approved, but it isn't the case at all.

That only happened because this issue got muddled up. You shouldn't blame anyone for linking issues and you can't turn back time so they are definitely relevant.

Poopooracoocoo avatar Sep 07 '20 04:09 Poopooracoocoo

So is this the right ask? "UWP and Win32 Reunion apps should have a default system menu that matches the app or system theme?"

stevewri avatar Oct 12 '20 19:10 stevewri

So is this the right ask? "UWP and Win32 Reunion apps should have a default system menu that matches the app or system theme?"

Yep.

shaheedmalik avatar Oct 13 '20 04:10 shaheedmalik

So is this the right ask? "UWP and Win32 Reunion apps should have a default system menu that matches the app or system theme?"

Why not use the WinUI context flyout control, instead of using the Win32 version, with or without app theme support?

mdtauk avatar Oct 13 '20 04:10 mdtauk

Because it requires the entire WinUI stack for a mere context menu? That means Win32 apps which previously took 1mb of RAM now take at least 15.

For. a. context. menu.

sylveon avatar Oct 13 '20 04:10 sylveon

Because it requires the entire WinUI stack for a mere context menu? That means Win32 apps which previously took 1mb of RAM now take at least 15.

For. a. context. menu.

This is a good point, providing the app does not use WinUI at all

mdtauk avatar Oct 13 '20 04:10 mdtauk

WinUI desktop apps totally can (and should) replace that by some sort of dev-customizable flyout. Probably UWP as well given the extension points required are added.

sylveon avatar Oct 13 '20 04:10 sylveon

That's why I was suggesting to restyle those menus. If it's up to devs to opt in, hardly any app will use it, which is what (I think) @shaheedmalik also thinks.

Poopooracoocoo avatar Oct 13 '20 05:10 Poopooracoocoo