locked
What is the API in metro c++ app to query resolution?

    Question

  • Hi,

    In win32, GetSystemMetrics can be used to query screen resolution. But this seems not available in metro app. Do you know what the alternative API is?

    Thanks,

    Fan


    Fan


    Tuesday, April 03, 2012 10:10 PM

Answers

  • Hi Fan,

    There is no way provided for a Metro style app to get the screen width and screen height. They can get their own window bounds and they can get resolution information from Windows::Graphics::Display::DisplayProperties.

    Why do you need the screen width and screen height? There may be a better way to achieve that goal. The typical reasons one would want that are either irrelevant for Metro style apps (window sizing and positioning) or provided in other ways (scaling, resolution, etc.)

    --Rob

    Wednesday, April 04, 2012 5:13 PM
    Owner

All replies

  • There is nothing direct. You can get information about the scaling and DPI of the monitor from Windows::Graphics::Display::DisplayProperties.

    The actual height and width of the screen shouldn't matter as much as the height and width of the Metro style app's window, which you can get from CoreWindow.Bounds.

    --Rob

    Wednesday, April 04, 2012 12:21 AM
    Owner
  • Hi Rob,

    Thanks for your reply. However, CoreWindow.Bounds returns different value when app is launched in snap view. I looked at Windows::Graphics::Display::DisplayProperties. DisplayProperties::ResolutionScale and DisplayProperties::LocalDpi are single integers. How should I use it to get the screen width and screen height?

    Thanks,


    Fan

    Wednesday, April 04, 2012 4:25 PM
  • Hi Fan,

    There is no way provided for a Metro style app to get the screen width and screen height. They can get their own window bounds and they can get resolution information from Windows::Graphics::Display::DisplayProperties.

    Why do you need the screen width and screen height? There may be a better way to achieve that goal. The typical reasons one would want that are either irrelevant for Metro style apps (window sizing and positioning) or provided in other ways (scaling, resolution, etc.)

    --Rob

    Wednesday, April 04, 2012 5:13 PM
    Owner
  • Hi Rob,

    I would like to create one DX texture on app starts up using screen resolution as default size. If the app starts in snap view mode, the texture size should be same as screen resolution, not the size of snap view size.

    As your last reply mentioned, if Metro style app couldn't get the screen width and screen height. I think app may have to use a fixed default size like 1920x1080 to start with. Your suggestion?

    Thanks,


    Fan

    Wednesday, April 04, 2012 7:06 PM
  •  I use the code enclosed to get the window size.

    	CoreWindow^ m_window = CoreWindow::GetForCurrentThread();
    	Rect bounds = m_window->Bounds;
    	
    	actualscreenwidth = (int) bounds.Width;
    	actualscreenheight = (int) bounds.Height;


    n.Wright

    Saturday, October 12, 2013 10:17 PM