上一篇博客<C# 获取当前屏幕DPI>,介绍了如何获取当前屏幕的DPI设置 本章主要介绍如何获取当前窗口所在屏幕的信息 当前屏幕信息 如果当前是单屏幕,可以直接获取主屏幕 var primaryScreen = Screen.PrimaryScreen; 如果当前是多屏,建议通过窗口句柄获取Screen信息 var window = Window.GetWindow(ExportButton);//获取当前主窗口 var intPtr = new WindowInteropHelper(win
原文:uwp - 获取当前屏幕宽高/应用宽高 public static Size GetScreen() { var applicationView = ApplicationView.GetForCurrentView(); var displayInformation = DisplayInformation.GetForCurrentView(); var bounds = applicationView.VisibleBounds; var scale = displayInforma
原文:WPF 获取鼠标屏幕位置.窗口位置.控件位置 public struct POINT { public int X; public int Y; public POINT(int x, int y) { this.X = x; this.Y = y; } } [DllImport("user32.dll")] public static extern bool GetCursorPos(out POINT lpPoint); //e.GetPosition(this); //(e
1.获取手机屏幕宽高: DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); int screenWidth = dm.widthPixels; int screenHeight = dm.heightPixels; 22.根据屏幕宽度为控件设置动态设置宽高: imageView.setImageResource(R.drawable.newscar); L