DragMove() and Maximize

前端 未结 6 1198
误落风尘
误落风尘 2020-12-16 01:32

I have a problem with my custom window (AllowTransparency, WindowStyle=None) in WPF. DragMove() method works good, but when I maximize window, or it maximizing automatically

6条回答
  •  一向
    一向 (楼主)
    2020-12-16 01:41

    The DragMove() method only works in the titlebar of the form so use:

    [DllImport("user32.dll")]
    public static extern IntPtr SendMessage(IntPtr hWnd, int wMsg, int wParam, int lParam);
    
    public static void StartDrag(Window window)
    {
        WindowInteropHelper helper = new WindowInteropHelper(window);
        SendMessage(helper.Handle, 161, 2, 0);
    }
    

    Dont forget to add System.Windows.Interop

提交回复
热议问题