Aero Snap not working for my application

拟墨画扇 提交于 2019-11-30 09:33:21

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.

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.

Edit: 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).

I doubt it is message handling, the message loop never sees the WM_KEYDOWN message. After trying various things unsuccessfully, I can only guess at Windows thinking your app is incompatible somehow. Using SetWindowsHookEx() in your program for example.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!