B
B
Boris the Animal2015-06-22 18:22:00
Programming
Boris the Animal, 2015-06-22 18:22:00

How to catch the moment when the window is placed on one of the sides of the screen (sticks, as it were), when pressing WIN + LEFT?

Interested in how to find out about it. Because, it seems to me, Windows clearly somehow makes itself felt that the window is not just placed to the side with its hands, but that it is "sticky".
Well, or how to programmatically stick a window without resorting to simulating pressing this combination?
In general, I am developing a WPF application, so someone may have come across such tags in those sections.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stanislav Makarov, 2015-06-23
@Casper-SC

I think you will have to study and partially repeat the logic of Windows in terms of gluing a window - i.e. get the size of the work area on the current monitor and make the window half the area with the desired position. From the application's point of view, there is no need to tell it that the window is sticky - it shouldn't matter to it whether it is sticky or manually resized to that size.
The old window size is remembered by the Windows window manager, as in the case of maximize / minimize - otherwise the old applications would not work with sticking, but they all work without problems, so the operating system does not require anything new.

S
Sergey, 2015-06-22
@zenden2k

> Interested in how to find out about this.
Unfortunately, Windows does not send a special message when doing this. It is possible to process a WM_SIZE message without having previously received a WM_SYSCOMMAND message.
> Well, or how to programmatically stick the
Crutch method:

RECT rc, originalRect;
SystemParametersInfo(SPI_GETWORKAREA, 0, &rc, 0);
GetWindowRect(hwnd, &originalRect);
SetWindowPos(hwnd, 0, rc.left, rc.top, (rc.right - rc.left) / 2, originalRect.bottom - originalRect.top, 0);
PostMessage(hwnd, WM_NCLBUTTONDBLCLK, HTTOP, 0);

Don't know how to do it without changing the window width. Not tested on multi-monitor configurations.
True, in fact, keystroke emulation will work better.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question