4
votes

I have created a borderless window using these styles: WS_VISIBLE | WS_POPUP | WS_OVERLAPPED

The problem is that the window can't be moved. I know that I could do something like getting mouse click position, and then calculate where the window would end up everytime there comes a WM_MOUSEMOVE.

But this solution is not stable, because when I move my mouse too fast, it gets out of the window, and then it won't react. I dont want to set up a hook, because they are too slow. I have searched the internet, but nothing came up at all.

What I ideally want to, is to create a window, that is able to be moved without borders or captions, where I don't need to track the mouse myself, but where Windows does it for me, like making the whole window a caption.

2
Why does the form need to be responsive to you intentionally moving it fast?Austin Brunkhorst
@AustinBrunkhorst Because that's how people expect windows to behave. If you started dragging a window, the window should end up where your drag ends, not at some point in-between where the mouse cursor happened to outrace the window.jamesdlin
@HansPassant: Maybe, didn't see that. But anyway, thanks for answering, jamesdlin.user2553662

2 Answers

5
votes

I know that I could do something like getting mouse click position, and then calculate where the window would end up everytime there comes a WM_MOUSEMOVE. But this solution is not stable, because when I move my mouse too fast, it gets out of the window, and then it won't react.

You can fix that by calling SetCapture when you receive the mouse click. You then will continue to receive WM_MOUSEMOVE even after the mouse cursor leaves your window. When the user is finished dragging and release the mouse cursor, you then should call ReleaseCapture.

What I ideally want to, is to create a window, that is able to be moved without borders or captions, where I don't need to track the mouse myself, but where Windows does it for me, like making the whole window a caption.

If you really want to do that, you could respond to the WM_NCHITTEST message and return HTCAPTION.

1
votes

try PostMessage(hwnd,WM_SYSCOMMAND,SC_SIZE+9,0) on WM_LBUTTONDOWN.