约束窗口位置到桌面工作区 [英] Constraining window position to desktop working area

查看:159
本文介绍了约束窗口位置到桌面工作区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想允许用户仅在桌面工作区域内部拖动我的Win32窗口。换句话说,他们不应该有窗口的任何部分扩展到监视器之外,也不应该窗口重叠任务栏。

I want to allow a user to drag my Win32 window around only inside the working area of the desktop. In other words, they shouldn't be able to have any part of the window extend outside the monitor(s) nor should the window overlap the taskbar.

喜欢做它的方式,会导致任何口吃。处理WM_MOVE消息和调用MoveWindow()重新定位窗口,如果它关闭工作,但我不喜欢MoveWindow()引起的闪烁效果。

I'd like to do it in a way that does cause any stuttering. Handling WM_MOVE messages and calling MoveWindow() to reposition the window if it goes off works, but I don't like the flickering effect that's caused by MoveWindow().

I也试图处理WM_MOVING,这防止需要通过在移动实际发生之前改变目标矩形来调用MoveWindow()。这解决了闪烁的问题,但是我遇到的另一个问题是,当一个拖动发生时,光标有一些时间从窗口中移动允许用户拖动窗口周围,而光标甚至不在窗口内。

I also tried handling WM_MOVING which prevents the need to call MoveWindow() by altering the destination rectangle before the move actually happens. This resolves the flickering problem, but another issue I run into is that the cursor some times gets aways from the window when a drag occurs allowing the user to drag the window around while the cursor is not even inside the window.

如何约束我的窗口而不会遇到这些问题?

How do I constrain my window without running into these issues?

推荐答案

具有多监视器设置的用户可以具有扩展到负x和y坐标或不是矩形的桌面。此外,一些用户使用替代的窗口管理器,例如LiteStep,它通过将它们移出屏幕来实现虚拟桌面;如果你试图打击这个,你的应用程序将打破这些用户。

Keep in mind that users with multi-monitor setups may have a desktop that extends into negative x- and y-coordinates, or that is not rectangular. Also, some users use alternative window managers such as LiteStep, which implement virtual desktops by moving them off-screen; if you try to fight this, your application will break for these users.

这篇关于约束窗口位置到桌面工作区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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