SFML community forums

Help => Window => Topic started by: Heihach on July 08, 2015, 06:35:31 pm

Title: Window Position While Moving
Post by: Heihach on July 08, 2015, 06:35:31 pm
Hey you all! This is my first post here, since I wasn't able to find an answer anywhere else.

The main thing I'm wondering right now is if it's possible to get the position of a Window while it's being moved/dragged by the user. I've looked a bit into Win32 API, but it seems like moving the window is a blocking action so that the position will only ever update after the drag is complete.

Is this the case? Is it a lost cause to try and interact with the window as it's being moved?

Thanks!
Title: Re: Window Position While Moving
Post by: kitteh-warrior on July 08, 2015, 07:52:42 pm
There is no sf::Event fired while the window is being moved, only once it has finished moving. A way to (possibly) get around this, is using a separate thread and using sf::Window::getPosition (http://www.sfml-dev.org/documentation/2.3/classsf_1_1Window.php#a2e6bc12612ea289afea8268fe37c8678). Though, I am not sure how well this works, if at all.

The main question is: why would you need this?
Title: Re: Window Position While Moving
Post by: Hapax on July 08, 2015, 09:46:30 pm
SFML processes Windows' messages and creates its own sf::Events for you to use. It doesn't give you access to the unused messages as they all get processed at once and it doesn't provide events on each movement of a window - just when it has finished moving.

However, you can create your window (still with SFML) without a title bar and draw your own, then move it manually.
I once created and posted the code for a draggable borderless window (http://en.sfml-dev.org/forums/index.php?topic=14391#msg101187), which would, consequently, allow you access to the exact position at all times.