How do I move a wpf window into a negative top value?

If I use dragMove the wpf window will not move to a location where the y value is negative. I can however set the windows top value to a negative value. Is there a simple way to enable dragMove to allow the top of the window to be moved above the displays 0 position?


It seems that this is the default window's handling of moveWindow. Verified with a call to SendMessage( hwnd, WM_SYSCOMMAND, SC_MOVE, null);


As I found, the window will move to "negative" location, but will then jump back. To prevent this you could do something like:

public partial class Window1: Window {

    public Window1() {

    private void Window_MouseDown(object sender, MouseButtonEventArgs e) {

    public struct WINDOWPOS {
        public IntPtr hwnd;
        public IntPtr hwndInsertAfter;
        public int x;
        public int y;
        public int cx;
        public int cy;
        public UInt32 flags;

    private static IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) {
        switch(msg) {
            case 0x46://WM_WINDOWPOSCHANGING
                if(Mouse.LeftButton != MouseButtonState.Pressed) {
                    WINDOWPOS wp = (WINDOWPOS)Marshal.PtrToStructure(lParam, typeof(WINDOWPOS));
                    wp.flags = wp.flags | 2; //SWP_NOMOVE
                    Marshal.StructureToPtr(wp, lParam, false);
        return IntPtr.Zero;

    private void Window_Loaded(object sender, RoutedEventArgs e) {
        HwndSource source = HwndSource.FromHwnd(new WindowInteropHelper(this).Handle);
        source.AddHook(new HwndSourceHook(WndProc));

Handling WM_WINDOWPOSCHANGING this way will prevent any movement of the window unless left mouse button is pressed. This includes maximizing the window and programmatic change of window position as well, so you'll have to adapt the code if you need another behavior.

Need Your Help

Is this a bug in Delphi 2009?

delphi generics interface delphi-2009

It certainly looks like a bug, but I only have the trial version so it may have been fixed.