using System; using System.Windows; using System.Windows.Interop; namespace Wpftest { public partial class MainWindow : Window { public MainWindow() { this.InitializeComponent(); // 在此点下面插入创建对象所需的代码。 } protected override void OnSourceInitialized(EventArgs e) { base.OnSourceInitialized(e); HwndSource hwndSource = PresentationSource.FromVisual(this) as HwndSource; if (hwndSource != null) { hwndSource.AddHook(new HwndSourceHook(this.WndProc)); } } private const int WM_NCHITTEST = 0x0084; private readonly int agWidth = 12; //拐角宽度 private readonly int bThickness = 4; // 边框宽度 private Point mousePoint = new Point(); //鼠标坐标 public