我如何获得屏幕的大小

How do I get the size of the screen?

本文关键字:屏幕 何获得      更新时间:2023-10-16

我想知道屏幕的宽度,以在win8应用中设置弹出窗口的宽度。

假设您是指屏幕的高度和宽度(或更准确的应用程序窗口的高度和宽度),您可以从window.bounds.bounds

中获取它

例如,以下是一个按钮后面的代码,将在该窗口上的文本框中显示当前窗口的宽度:

void App68::MainPage::Button_Click_1(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
    txtWidth->Text = Window::Current->Bounds.Width.ToString();
}