Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DisplayInformation exception in WinUI3 preview4 #4228

Closed
arivoir opened this issue Feb 17, 2021 · 7 comments
Closed

DisplayInformation exception in WinUI3 preview4 #4228

arivoir opened this issue Feb 17, 2021 · 7 comments
Assignees
Labels
appModel-win32 Exclusive to WinUI 3 Win32 Desktop apps product-winui3 WinUI 3 issues question version-winui3preview4 WinUI 3 Preview 4 issues wct

Comments

@arivoir
Copy link

arivoir commented Feb 17, 2021

Since preview 4 the following code is throwing an exception

Windows.Graphics.Display.DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel

Element not found. (0x80070490)
at WinRT.ExceptionHelpers.ThrowExceptionForHR(Int32 hr)

Is this a bug, or is there any way round?

@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Feb 17, 2021
@marb2000 marb2000 self-assigned this Feb 17, 2021
@marb2000 marb2000 added question appModel-win32 Exclusive to WinUI 3 Win32 Desktop apps version-winui3preview4 WinUI 3 Preview 4 issues and removed needs-triage Issue needs to be triaged by the area owners labels Feb 17, 2021
@marb2000
Copy link
Contributor

DisplayInformation.GetForCurrentView() is no longer supported in WinUI 3 in Desktop. You should use XamlRoot's RasterizationScale

@maxkatz6
Copy link
Contributor

Will those unsupported classes removed from public API?

@marb2000
Copy link
Contributor

Some APIs belong to WinUI and Reunion projects (e.g. Microsoft.*), others belong to the UWP Platform that ships with the Windows 10 OS. For example, the Windows.Graphics.Display.DisplayInformation works well in UWP apps. We can't remove these APIs. But we do plan to remove the WinUI APIs that don't work from the supported versions (e.g. Reunion 0.5). For example, given Reunion 0.5 will support only WinUI 3 in Desktop, we should remove the Dispatcher,CoreDispatcher, Current, and CoreWindow properties from the Microsoft.UI.Xaml.Window class. Does this make sense to you?

@sigmarsson
Copy link

sigmarsson commented Feb 19, 2021

@marb2000 How shall I access the current view if DisplayInformation.GetForCurrentView() is deprecated ?

image

@BorzillaR
Copy link

BorzillaR commented Mar 30, 2021

@marb2000, is there suggested replacement for DisplayInformation.ScreenHeightInRawPixels property? I did not find it in this document.

@krschau krschau added the product-winui3 WinUI 3 issues label Jul 14, 2021
@krschau
Copy link
Contributor

krschau commented Jul 16, 2021

@sigmarsson The answer depends on what you needed the current view for. For the TitleBar in your example, does this help?
https://docs.microsoft.com/en-us/windows/winui/api/microsoft.ui.xaml.window.settitlebar?view=winui-3.0

More generally, hopefully the answer can be found in this list:
https://docs.microsoft.com/en-us/windows/apps/desktop/modernize/desktop-to-uwp-supported-api#classes-with-getforcurrentview-methods

If you're having concerns and this doesn't address them, please open a new issue.

@krschau
Copy link
Contributor

krschau commented Jul 16, 2021

@BorzillaR If you want to get monitor info to replace ScreenHeightInRawPixels, you can try using MonitorFromWindow to get the HMONITOR and plug that into GetMonitorInfoW.

If this doesn't work for what you need, please open a new issue and we'll get it sorted out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
appModel-win32 Exclusive to WinUI 3 Win32 Desktop apps product-winui3 WinUI 3 issues question version-winui3preview4 WinUI 3 Preview 4 issues wct
Projects
None yet
Development

No branches or pull requests

7 participants