microsoft / microsoft-ui-xaml

WinUI: a modern UI framework with a rich set of controls and styles to build dynamic and high-performing Windows applications.
MIT License
6.37k stars 683 forks source link

AppWindow.ResizeClient() Problems #9563

Open tingjiangcao opened 7 months ago

tingjiangcao commented 7 months ago

Describe the bug

Objective: Customize the title bar and fix the window size to (900, 565) AppWindow.TitleBar.ExtendsContentIntoTitleBar = true; AppWindow.ResizeClient(new SizeInt32(900, 565));

Problem 1: The rendered result is directly (900, 565). But this is the logical size, if the monitor is 150% scaled, the rendering result should be (9001.5, 5651.5) For this, I had to achieve it in the following way: var scale = mainPanel.XamlRoot.RasterizationScale; int width = (int)(950 scale); int height = (int)(565 scale); AppWindow.ResizeClient(new SizeInt32(width, height));

Question 2: ResizeClient sets the height of the content area, so I need to subtract the height of the title bar. The document says the height of the title bar is 48, the actual height is 32*1.5=48

Question 3: If it is a direct AppWindow.Resize (9001.5, 5651.5), then the actual rendered size of the window will be a dozen points smaller in width and height each.

The actual size of the rendered window needs to be viewed in a screenshot. Recommended use of screenshot software snipaste.

My ultimate goal is: immersive title bar, the window specified size is fixed, can not be maximized, can not resize the window, start the position of the center. Realize the above features, winui3 api is either missing, or off, or bugs. maddening. My next app will go back to wpf. Or electron.

image

Steps to reproduce the bug

.

Expected behavior

No response

Screenshots

No response

NuGet package version

None

Windows version

No response

Additional context

No response

github-actions[bot] commented 7 months ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

NicholasChrzan commented 7 months ago

I'm not sure how this is a bug. The documentation for the AppWindow.ResizeClient clearly states they are in Win32 coordinates which are not the scaled logical coordinates used in XAML, so you'll have to adjust for the DPI of the display. To accomplish what you are after you'll need to manipulate the window style using the win32 SetWindowLong. While it would be nice if these options were included on the AppWindow (or the Window itself) not having them doesn't constitute a bug.