Pergunta

I have a window that has to behave as normally as possible to the Windows 7 standard despite having ResizeMode set to CanMinimize.

I acknowledge the poor sense in this route, but it's one of the only ways I'm aware of of hosting non-WPF content (WinFormsHost, etc) in a chromeless/borderless parent window (As AllowsTransparency (the traditional way) would normally conflict with it (causing it to not render at all)).

With this in mind, I have written my own resize and gesture code for the window (snap to side, maximize when dragged to top, etc) and this all works brilliantly.

I would have the expected behavior the user gets from WinKey + Direction (Left and Right snap the window to Left or Right, while Up maximizes it and Down restores it to normal size) with no difficulty as well, however it seems the system swallows this particular combination before it even reaches the application. When directional OR windows keys are pressed, the events are triggered appropriately, but the combination just will not trigger it whatsoever.

So my question is thus: Is it possible to react to this combination in a relatively ordinary WPF application without inserting keyboard hooks into the system?

Thanks for your time.

Foi útil?

Solução

Have found a solution as per Gustavo Cavalcanti's answer to a similar question. The application is now catching the individual key press events, and I am able to determine keyboard state and act accordingly when the arrow keys are pressed (via checks on LWin/RWin and arrows with Keyboard.IsKeyDown).

This is an alright solution for now but it doesn't quite match Windows' normal functionality as windows are expected to move/dock in the instant that the user presses the arrow key rather than when it is released.

All the same, better than nothing and works out of the box with minimal extra code and no other dependencies/libraries. Superior solutions are still welcome, and I won't be marking this answer as a solution as the problem hasn't been solved comprehensively.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top