本文介绍了我怎样才能获得活动的屏幕尺寸是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我所寻找的是 System.Windows.SystemParameters.WorkArea
对于这个窗口是目前显示器相当。
What I am looking for is the equivalent of System.Windows.SystemParameters.WorkArea
for the monitor that the window is currently on.
澄清:有问题的窗口 WPF
,而不是的WinForm
Clarification: The window in question is WPF
, not WinForm
.
推荐答案
Screen.FromControl
, Screen.FromPoint
和 Screen.FromRectangle
应该可以帮助您与此有关。例如在的WinForms这将是:
Screen.FromControl
, Screen.FromPoint
and Screen.FromRectangle
should help you with this. For example in WinForms it would be:
class MyForm : Form
{
public Rectangle GetScreen()
{
return Screen.FromControl(this).Bounds;
}
}
我不知道等效呼吁WPF的。因此,你需要做的是这样的扩展方法。
I don't know of an equivalent call for WPF. Therefore, you need to do something like this extension method.
static class ExtensionsForWPF
{
public static System.Windows.Forms.Screen GetScreen(this Window window)
{
return System.Windows.Forms.Screen.FromHandle(new WindowInteropHelper(window).Handle);
}
}
这篇关于我怎样才能获得活动的屏幕尺寸是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!