【发布时间】:2015-09-10 15:18:05
【问题描述】:
我正在创建一个在 Windows 8.1 Pro 上运行的 Windows 桌面应用程序。
我可以使用此属性以编程方式将其最小化:
WindowState.Minimized;
有没有办法完全隐藏它,或者禁止用户关闭它?
我尝试了所有these StackOverflow solutions,但是
它们对我不起作用。
我试过了
private const int GWL_STYLE = -16;
private const int WS_SYSMENU = 0x80000;
[DllImport("user32.dll", SetLastError = true)]
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
[DllImport("user32.dll")]
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
和
var hwnd = new WindowInteropHelper(this).Handle;
SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_SYSMENU);
然后我尝试将以下方法添加到我的 windows 类中
protected override void OnClosing(CancelEventArgs e)
{
base.OnClosing(e);
e.Cancel = true;
}
我尝试了这个属性
WindowStyle = WindowStyle.None;
仍然没有运气。
我怎样才能得到它?
我正在使用 VS2015 和 WPF
【问题讨论】:
-
在 XAML 中使用
<Window ... WindowStyle="None">。添加您自己的按钮。 -
已经试过了,但是不行
-
不可能,我做了几次,总是很好。工商管理硕士你有一些在运行时禁用它的窗口逻辑。 msdn.microsoft.com/en-us/library/…
标签: c# wpf windows desktop-application