Aero Snap不适用于我的应用程序 [英] Aero Snap not working for my application

查看:296
本文介绍了Aero Snap不适用于我的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,Aero Snap不能与我正在工作的应用程序(Windows桌面,本机C + +应用程序),我有点困惑的发生了什么,因为它似乎应该只是工作,

I have a problem with Aero Snap not working with the application I'm working on (Windows desktop, native C++ application), and I'm a bit confused as to what's happening, as it seems like it should just work, out of the box.

我在一个mininal win32应用程序中使用了Spy ++,当我按下Win-Left时会收到以下消息:

I've used Spy++ on a mininal win32 application, and get the following messages when I press Win-Left:

< 00070> 00030D1C P WM_KEYDOWN nVirtKey:VK_LWIN cRepeat:1 ScanCode:5B fRepeat:0 fUp:0
< 00071> 00030D1C P WM_KEYDOWN nVirtKey:VK_LWIN cRepeat:1 ScanCode:5B fRepeat:1 fUp:0
< 00072> 00030D1C P WM_KEYDOWN nVirtKey:VK_LWIN cRepeat:1 ScanCode:5B fRepeat:1 fUp:0
< 00088> 00030D1C S WM_GETMINMAXINFO lpmmi:0043FCBC

< 00089> 00030D1C R WM_GETMINMAXINFO lpmmi:0043FCBC

< 00090> 00030D1C S WM_WINDOWPOSCHANGING lpwp:0043FCC4

< 00091> 00030D1C S WM_GETMINMAXINFO lpmmi:0043F8E8

< 00092> 00030D1C R WM_GETMINMAXINFO lpmmi:0043F8E8

< 00093> 00030D1C R WM_WINDOWPOSCHANGING

..等等

<00070> 00030D1C P WM_KEYDOWN nVirtKey:VK_LWIN cRepeat:1 ScanCode:5B fRepeat:0 fUp:0 <00071> 00030D1C P WM_KEYDOWN nVirtKey:VK_LWIN cRepeat:1 ScanCode:5B fRepeat:1 fUp:0 <00072> 00030D1C P WM_KEYDOWN nVirtKey:VK_LWIN cRepeat:1 ScanCode:5B fRepeat:1 fUp:0 <00088> 00030D1C S WM_GETMINMAXINFO lpmmi:0043FCBC
<00089> 00030D1C R WM_GETMINMAXINFO lpmmi:0043FCBC
<00090> 00030D1C S WM_WINDOWPOSCHANGING lpwp:0043FCC4
<00091> 00030D1C S WM_GETMINMAXINFO lpmmi:0043F8E8
<00092> 00030D1C R WM_GETMINMAXINFO lpmmi:0043F8E8
<00093> 00030D1C R WM_WINDOWPOSCHANGING
.. and so on

所以我可以看到左键的WM_KEYDOWN没有到达应用程序,但我得到了航空快照调整大小窗口的东西。

So I can see that the WM_KEYDOWN for the left key isn't reaching the application, but I'm getting the aero snap "resize window" stuff instead.

当我Spy ++我的应用程序,我可以看到左键没有被截获,而是传递给应用程序,所以我没有得到任何捕捉善良。

When I Spy++ my application, I can see that the left key isn't being "intercepted", but instead being passed on to the application, so I don't get any snapping goodness.

< 00043> 000F0F12 P WM_KEYDOWN nVirtKey:VK_LWIN cRepeat:1 ScanCode:5B fRepeat:0 fUp:0

< 00044> 000F0F12 P WM_KEYDOWN nVirtKey:VK_LWIN cRepeat:1扫描码:5B fRepeat:1 fUp:0

< 00045> 000F0F12 P WM_KEYDOWN nVirtKey:VK_LWIN cRepeat:1 ScanCode:5B fRepeat:1 fUp:0

< 00060> 000F0F12 P WM_KEYUP nVirtKey:VK_LEFT cRepeat:1 ScanCode:4B fRepeat:0 fUp:1

<00043> 000F0F12 P WM_KEYDOWN nVirtKey:VK_LWIN cRepeat:1 ScanCode:5B fRepeat:0 fUp:0
<00044> 000F0F12 P WM_KEYDOWN nVirtKey:VK_LWIN cRepeat:1 ScanCode:5B fRepeat:1 fUp:0
<00045> 000F0F12 P WM_KEYDOWN nVirtKey:VK_LWIN cRepeat:1 ScanCode:5B fRepeat:1 fUp:0
<00060> 000F0F12 P WM_KEYUP nVirtKey:VK_LEFT cRepeat:1 ScanCode:4B fRepeat:0 fUp:1

我要深入研究我们的消息处理的核心, )

I'm going to dig into the cores of our message handling and see what's going on, but I'll take all the tips I can get :)

编辑我注意到了Win-Up和Win-Shift -Left / Right实际上正常工作,所以它只是Win-Down和Win-Left / Right,没有被aero拍到正确的位置/大小。

Edit I noticed that Win-Up and Win-Shift-Left/Right actually work correctly, so it's just Win-Down and Win-Left/Right that aren't being "aero snapped" into the correct position/size.

编辑确定,问题似乎在于我的窗口没有使用WS_THICKFRAME标志创建。如果我添加标志,snap工作。现在,我实际上不想在那里的边界在第一,但至少我知道是什么导致奇怪的行为..

Edit Ok, the problem seems to be that my window wasn't been created with the WS_THICKFRAME flag. If I add the flag, snap works. Now, I don't actually want the border there in the first place, but at least I know what was causing the weird behavior..

希望最后编辑删除边框就像响应WM_NCCALCSIZE一样简单,并使客户端占据整个窗口。

Hopefully a final edit Getting rid of the border was as simple as responding to WM_NCCALCSIZE, and making the client occupy the whole window.

推荐答案

p>我不记得具体的消息,但是如果您为主窗口处理WM_MOVING / WM_MOVE和/或WM_SIZING / WM_SIZE消息,则会禁用Aero Snap。如果这些没有达到 DefWindowProc Aero Snap将无法工作。我想DefWindowProc负责实现Aero Snap,所以如果你确保那些消息达到它,这可能有帮助。

I can't remember the specific messages, but Aero Snap is disabled if you process the WM_MOVING/WM_MOVE and/or WM_SIZING/WM_SIZE messages for the main window. If these do not reach DefWindowProc Aero Snap won't work. I guess DefWindowProc is responsible for implementing Aero Snap, so if you make sure those messages reach it, that might help.

我发现这实现自定义窗口拖动代码,所以应用程序在窗口被拖动时继续执行和更新屏幕,这意味着处理这些消息,但它禁用了Aero Snap。

I discovered this implementing custom window dragging code so the application continues to execute and update the screen while the window is dragged, which meant processing these messages, but it disabled Aero Snap.

编辑:进一步检查,我提到的应用程序处理WM_SYSCOMMAND并检查(wParam& 0xFFF0)== SC_MOVE 以指示窗口移动开始。然后它返回0并通过周期性地更新窗口位置来模拟窗口拖动,同时仍然运行应用程序,绘图等。这使得Windows认为窗口是不可移动的,用户不能拖动它,但是我的应用程序正在更新位置它看起来仍然被拖动,直到WM_LBUTTONUP。显然,Windows不会尝试任何Aero Snap东西,如果它不认为窗口被拖动。也许你的应用程序做类似的事情(如果任何人有一个更好的方法来保持应用程序在拖动期间运行,我有兴趣听)。

On further inspection, the application I mentioned handles WM_SYSCOMMAND and checks (wParam & 0xFFF0) == SC_MOVE to indicate a window move beginning. It then returns 0 and simulates the window dragging by updating the window position periodically whilst still running the application, drawing etc. This causes Windows to think the window is unmovable and that the user cannot drag it, but my application is updating the position to make it look like it's still being dragged, until WM_LBUTTONUP. Obviously Windows won't try any Aero Snap stuff if it doesn't think the window is being dragged. Maybe your application does something similar (if anyone has a better way to keep the app running during a drag, I'd be interested to hear).

这篇关于Aero Snap不适用于我的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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