如何将WPF窗口的移动/调整大小限制为桌面边界 [英] How to limit a WPF window's move/resize to desktop boundaries

查看:400
本文介绍了如何将WPF窗口的移动/调整大小限制为桌面边界的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!

如何使运行WPF应用程序的窗口的所有部分始终保持可见状态.我想防止移动或调整此窗口的大小会使某些部分超出桌面的边界,使它们不可见.
就像粘性窗户一样,但又有所不同!

感谢您对此提供的任何帮助.

感谢您的考虑!

HZ

Hi everybody!

How can I keep all parts of a window running a WPF application visible at all times. I want to prevent that moving or resizing this window will make some parts go outside the desktop''s boundaries making them invisible.
Like sticky window, but its different!

Any help on this is appreciated.

Thanks for your consideration!

HZ

推荐答案

我对您的建议是挂到窗口的WindowProc中.这里是有关如何执行此操作的文章: http://softwarekishorekoney.blogspot. com/2009/10/wpf-and-windows-messageswndproc.html [ ^ ].然后,如果窗口被移动或调整大小,则可以截取消息以提取该信息.通过检测桌面的几何形状,您将能够知道是否可以移动或调整窗口的当前位置.

最好的问候,

—MRB
My advice to you would be to hook into the window''s WindowProc. Here''s an article on how to do that: http://softwarekishorekoney.blogspot.com/2009/10/wpf-and-windows-messageswndproc.html[^]. Then if the window gets moved or resized you can intercept the messages to extract that information. By detecting your desktop geometry you will be able to tell if a move or a resize is possible to/at the current position of your window.

Best Regards,

—MRB


这篇关于如何将WPF窗口的移动/调整大小限制为桌面边界的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆