Saturday, 31 August 2013

Determining when a WPF window is being moved

Determining when a WPF window is being moved

I'm working on a class derived from the WPF Window class that behaves as
an applicaton toolbar window called AppBarWindow. I have been able to find
various WinForms implementations, but no WPF implementtions.
I've got a lot of the code working, but I need to know when the user
starts dragging the window around the screen and when they stop, as the
window's behavior will differ. The default WPF handling isn't quite right,
so I've implemented my own Window Procedure and installed it using an
HwndSource object.
I've got this working in an applicaton at work that does not have a
non-client area. In that case, there's a LeftMouseButtonDown event handler
that sets a flag to true, then calls the DragMove method which drags the
window around. When that method returns, I set the flag to false.
Everything works.
But I'm working now on a general class that won't use the DragMove method.
I can add another LeftMouseButtonDown handler for the window, but I don't
believe that will get called if the mosue is in the non-client area.
How am I going to detect that the user is dragging thw window and when
they've stopped in this case?

No comments:

Post a Comment