Aero Snap does not work for my application

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 is happening, as it seems like it should just work, out of the box .

I used Spy ++ in the win32 gadget and get the following messages when I click 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 fUpkt 000KWKW 000KDVEYKEY 00072> 000PKV0000 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
.. etc.

So, I see that WM_KEYDOWN for the left key does not reach the application, but instead I get an "resize window" aerobic binding.

When I Spy ++ my application, I see that the left key is not "intercepted", but instead is passed to the application, so I do not get any grabbing.

<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 delve into the messaging engine and see what happens, but I'll take all the tips I can get :)

Change I noticed that Win-Up and Win-Shift-Left / Right actually work correctly, so it is just Win-Down and Win-Left / Right that are not “disconnected” to the correct position / size.

Edit Well, the problem is that my window was not created using the WS_THICKFRAME icon. If I add a flag, click the works. Now I really do not want the border there, but at least I know what caused the strange behavior.

Hope final editing . Getting rid of the border was as simple as replying to WM_NCCALCSIZE, and getting the client to occupy the entire window.

+7
c ++ windows-7 winapi aero
source share
2 answers

I cannot recall specific messages, but Aero Snap is disabled if you process WM_MOVING / WM_MOVE and / or WM_SIZING / WM_SIZE messages for the main window. If they do not reach DefWindowProc , then Aero Snap will not work. I think DefWindowProc is responsible for implementing Aero Snap, so if you make sure that these messages reach it, this may help.

I discovered this code for dragging a custom window so that the application continues to execute and refresh the screen while dragging the window, which meant processing these messages, but it disabled Aero Snap.

Edit: Upon further verification, the application I mentioned treats WM_SYSCOMMAND and checks (wParam & 0xFFF0) == SC_MOVE to indicate the start of window movement. Then it returns 0 and simulates dragging the window, periodically updating the position of the window while the application, drawing, etc. are still running. This makes Windows think that the window is stationary and that the user cannot drag it, but my application updates the position to make it look like it is still being dragged to WM_LBUTTONUP. Obviously, Windows will not try to use Aero Snap unless it thinks the window is being dragged. Maybe your application does something similar (if someone has a better way to save the application while dragging and dropping, I would be interested to hear).

+4
source share

I doubt this is message processing, the message loop never sees the WM_KEYDOWN message. After unsuccessful attempts, I can only guess that Windows is not compatible with your application. For example, using SetWindowsHookEx () in your program.

+2
source share

All Articles