手动最大化应用程序时的屏幕分辨率问题
在我们的 WPF 应用程序中,我们使用 WindowStyle="None" 来为我们的应用程序提供更加自定义的外观。最大化/最小化按钮位于同一位置,但样式按照我们想要的方式进行。
因此,我们劫持了最大化和最小化行为并手动执行。我们正在执行以下操作:
this.Top = myScreen.WorkingArea.Top;
this.Left = myScreen.WorkingArea.Left;
this.Width = myScreen.WorkingArea.Width;
this.Height = myScreen.WorkingArea.Height;
此处,如果用户在多显示器设置上运行,则 myScreen 是应用程序中心点所在的屏幕。
在某些设置中,并且看似没有连接,点击最大化按钮会将应用程序的大小扩展到超出显示器的实际可视区域。它在我和另一个开发人员的设置中失败了,但我的老板的多显示器设置它工作得很好。
我的显示器设置如下:
显示器 2(左)
Top, Left: 0, -1280
Resolution: 1280, 1024
显示器 1(右,笔记本电脑)
Top, Left: 0, 0
Resolution: 1680, 1050
当我手动将应用程序的大小调整为最大化时应有的大小时,我得到以下值:
Top, Left: 0, -1024
Height, Width: 792, 1024
我最近更新了笔记本电脑上的显示驱动程序,并且不存在更新的驱动程序。除此之外我无法解释这种现象。还有其他人有这方面的经验吗?这可能是每像素点数转换问题还是其他问题?我无法从这里找到任何答案或搜索谷歌...任何帮助将不胜感激!
In our WPF applicaiton, we're using WindowStyle="None" in order to give our application a more custom look. The maximize/minimize buttons are in the same place, but styled the way we want them.
As such, we're hijacking the maximize and minimize behavior and doing it manually. We're doing the following:
this.Top = myScreen.WorkingArea.Top;
this.Left = myScreen.WorkingArea.Left;
this.Width = myScreen.WorkingArea.Width;
this.Height = myScreen.WorkingArea.Height;
Here, myScreen is the Screen where the center point of the application lies, in the event the user is running on a multi-monitor setup.
On certain setups, and with seemingly no connection, hitting the maximize button will extend the size of the application way past the actual, viewable area of the monitor. It fails this way on my and another developers setup, but my bosses multi-monitor setup it works just fine.
My monitor setup is as follows:
Monitor 2 (left)
Top, Left: 0, -1280
Resolution: 1280, 1024
Monitor 1 (right, laptop)
Top, Left: 0, 0
Resolution: 1680, 1050
When I manually resize the application to the size it should be when maximized, I get the following values:
Top, Left: 0, -1024
Height, Width: 792, 1024
I fairly recently updated the display drivers on my laptop, and no newer ones exist. Other than that I can't explain this phenomenon. Does anyone else have any experience with this? Is this perhaps a dots-per-pixel conversion issue or something? I can't find any answers from here or searching google... Any help would be greatly appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否看过此页面 - 考虑任务栏最大化窗口(WindowStyle=None)?另外,这里是一个开发人员的博客条目,位于他的控件上made 就是这样做的(尚未发布源代码,但声称很快就会发布)。
Have you seen this page - Maximizing window (with WindowStyle=None) considering Taskbar? Also, here is a developer's blog entry on a control he made that does this (hasn't released the source code yet, but claims it will be released soon).