AppWindow (WAS) titlebar customization & WinUI 3 titlebar customization #2312
Unanswered
AzAgarampur
asked this question in
Ideas
Replies: 1 comment 1 reply
-
https://portal.productboard.com/winappsdk/1-windows-app-sdk/c/48-integrate-appwindow-with-winui-3 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
So it seems there are two ways to customize a titlebar for a desktop app, (correct me if I'm wrong)
Window.ExtendsContentIntoTitleBar
. This will: recalculate the client area of the window and remove the top frame (titlebar) by handlingWM_NCCALCSIZE
, extends the default DWM frame into the background, set the window frame's theme (according to the user's theme settings), and then draws the WinUI 3 caption buttons on top.AppWindowTitleBar.ExtendsContentIntoTitleBar
. This will: set window attributes so that the caption buttons are not drawn, and then draw the appropriate caption buttons/titlebar using a separate pair of DirectComposition & Direct3D devices.Approach number 2 seems to be the best one. Not only does it look better, but it is more complete. In fact, it is almost doing the same thing that
ApplicationFrameHost.exe
does to show UWP application's windows (CoreWindow
). WinUI 3's "titlebar" looks completely out of place, with tiny caption buttons that jitter and jump all over the place when resizing, and they also show the DWM frame beneath them, making it appear as if there are two titlebars. Another reason number 2 is better is because it can allow titlebar customization from any ui framework, as the titlebar isn't linked to any XAML UI elements, and this method of customization does not require Windows 11. You can see Windows 10'sApplicationFrame
window have the same drawing behavior. I don't know why it is currently supported on Windows 11 only.My suggestion is that WinUI 3 should "forward" its titlebar customization calls to
Microsoft.UI.Windowing.AppWindow
. Since WinUI will maintain complete control of the Window/Graphics of the app, it can also forward other behavior toMicrosoft.UI.Windowing.AppWindow
instead of re-implementing it.There are a few other things I was thinking would be cool if WinUI 3 and Windows can do:
AppWindow
can have some private/internal functions that WinUI 3 can call so that a XAML UI element/Visual can act as the title. This is just like what UWP currently does. This routine could also be made public and accept anIDCompositionVisual*
so that classic Win32 apps that use a DirectComposition based UI framework (that isn't WinUI 3, XAML, etc) can useAppWindow
to allow aVisual
to act as the titlebar. In this case,AppWindow
may useDCompositionAttachMouseDragToHwnd
to make it act like the titlebar.AppWindow
and Windows (the DWM,ApplicationFrame
, etc) itself should stop usingDrawThemeTextEx/TextOut/DrawText
to draw text for the titlebars of customAppWindow
titlebars,ApplicationFrameWindow
tilebars, and standard Win32HWNDs
. Using these GDI based function doesn't allow certain things, like color emojis as caption text, text styling, etc. Since the DWM controls basically every window, it could use Direct2D'sDrawText
to draw the window caption. UWP andAppWindow
should also do the same.AppWindow
should be more like the UWP CompactOverlay, rather than simply making a window always on-top and making it have only a close button.Once again, if some of these features could be used from WinUI 3 only by "propagating" its actual functionality as calls into
AppWindow
, that would make it a lot better than having to use 2 separate things.Overall I'm very happy with
AppWindow
and how it'll help developers have easy customization via the system, just like how UWP apps have it. However, I think these few suggestions will make it even better.Beta Was this translation helpful? Give feedback.
All reactions