开发者

Form move events in Windows Forms

开发者 https://www.devze.com 2023-01-08 02:18 出处:网络
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.

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 proper开发者_如何学运维ty 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!


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...


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消