我正在寻找的是窗口当前所在的监视器的System.Windows.SystemParameters.WorkArea
等价物。
Clarification:有问题的窗口是WPF
,不是WinForm
。
发布于 2008-10-31 17:09:33
Screen.FromControl
、Screen.FromPoint
和Screen.FromRectangle
应该会在这方面帮助你。例如,在WinForms中,它将是:
class MyForm : Form
{
public Rectangle GetScreen()
{
return Screen.FromControl(this).Bounds;
}
}
我不知道WPF有没有类似的调用。因此,您需要执行类似于此扩展方法的操作。
static class ExtensionsForWPF
{
public static System.Windows.Forms.Screen GetScreen(this Window window)
{
return System.Windows.Forms.Screen.FromHandle(new WindowInteropHelper(window).Handle);
}
}
发布于 2009-04-13 15:44:50
您可以使用此命令获取主屏幕的桌面工作空间边界:
System.Windows.SystemParameters.WorkArea
这对于获取主屏幕的大小也很有用:
System.Windows.SystemParameters.PrimaryScreenWidth
System.Windows.SystemParameters.PrimaryScreenHeight
发布于 2010-05-25 15:23:44
此外,您可能还需要:
以获得所有监视器的组合大小,而不是一个特定的监视器。
https://stackoverflow.com/questions/254197
复制相似问题