C # Move Stop Stopped Event

Is there any event in C # that fires when the STOPS form is moved. Until he moves.

If there is no event for this, is there a way to do this using WndProc?

+4
source share
5 answers

The ResizeEnd event is fired when the move completes. Perhaps you could use this.

+12
source

This is not a fault-tolerant solution, but it is pure .NET, and it is dead simple. Add a timer to your form, set its relatively short delay (100-150 ms seemed good to me). Add the following code for the Form.LocationChanged and Timer.Tick events:

private void Form_LocationChanged(object sender, EventArgs e) { if (this.Text != "Moving") { this.Text = "Moving"; } tmrStoppedMoving.Start(); } private void Timer_Tick(object sender, EventArgs e) { tmrStoppedMoving.Start(); this.Text = "Stopped"; } 

If you need more accurate processing (knowing that when the mouse button is released in the title bar, etc.), you will probably have to dive into monitoring Windows messages.

+2
source

Just set the flag to true when firing onmove events. If the mouseup event occurs and the flag is true, the form stops moving.

I admit that this probably will not work if the user moves the form through the keyboard, but this is quite rare.

0
source

I had the same problem with a user control, but it does not have a ResizeEnd event. The solution that worked was to override the WndProc method and listen for EXITSIZEMOVE.

See an example here.

0
source

I tested the ResizeChanged event and it works fine, however I don't know the relationship between moving and resizing, but it works for me

0
source

All Articles