有人能告诉我如何从WPF窗口中删除关闭(X)按钮吗?我可以通过以下代码禁用它,但无法将其删除:
private const uint SC_CLOSE = 0xF060;
[DllImport("user32.dll")]
private static extern IntPtr GetSystemMenu(IntPtr hwnd, bool revert);
[DllImport("user32.dll")]
private static extern bool DeleteMenu(IntPtr hMenu, uint position, uint flags);
private void Window_Loaded(object sender, RoutedEventArgs e)
{
WindowInteropHelper helper = new WindowInteropHelper(this);
IntPtr hwnd = GetSystemMenu(helper.Handle, false);
DeleteMenu(hwnd, SC_CLOSE, 0);
}