由于某种原因,必须使用Win32 API来进行窗体无边框的处理,以下摘录摆渡得到的部分结果..
一、
[DllImport("User32.dll", CallingConvention = CallingConvention.Winapi)] public static extern void SetWindowLong(IntPtr handle, int oldStyle, long newStyle); IntPtr hwnd = new System.Windows.Interop.WindowInteropHelper(this).Handle; SetWindowLong(hwnd, -16, 369164288);
使用VS每次启动或者编译项目的时候都会弹出窗口报错,无法忍受。
二、
[DllImport("User32.dll", CharSet = CharSet.Auto)] public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong); SetWindowLong(this.Handle, -16, 369164288);
代码为五楼的回复内容,其中“this.Handle”报错。
结果
目前使用代码为
[DllImport("User32.dll", CharSet = CharSet.Auto , CallingConvention = CallingConvention.Winapi)] public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong); private void Window_Loaded(object sender, RoutedEventArgs e) { IntPtr hwnd = new System.Windows.Interop.WindowInteropHelper(this).Handle; SetWindowLong(hwnd, -16, 369164288); }
:biggrin: :biggrin: 感谢博主无私的分享