views:

30

answers:

2

Hello!

My problem is the following: i have a state machine inside an app and i need to be able to pause the current states's ProcessInput function as long as the user moves the form along the screen.

I have a property called "Paused" on the state which does that and i override the OnMove event of the form so that the property is set to true when the event fires.

How do I resume the ProcessInput function of the state when the user is no longer moving the form? (To be more specific, i am looking for an event to put a "state.Paused = false" in it)

Thx in advance for your help!

+1  A: 

Not sure if there's a specific event you can listen for, but how about using some sort of timer based workaround?

Create a timer, reset and enable the timer every time a move event occurs. Once the timer actually fires (hasn't been reset for the duration it's set to), then set state.Paused = false.

May be a bit rudimentry, but it should work...

Jaymz
yes, it could be a solution. thanks for the input!
cantrem
+1  A: 

You need WM_MOVE message, it is send when the move is done. I don't remember whether there is a handler (an event) in WinForms for it, but in worst case you can override window's WndProc and process the message manually - in "old school" C style.

Gobra
i searched and i couldn't find any handler. i guess i'll have to dig a little bit further to learn how to operate with WM_MOVE. thanks, it seems like this is what i need.
cantrem
.NET lacks some Win32 api features, but it's really easy to add the functionality: you can find C++ header with WM_MOVE constant and override WndProc of the window (form) class to handle this message.
Gobra