去掉关闭按钮同时禁用alt+f4进行关闭

public int ctype = 0;

private const int GWL_STYLE = -16;
private const int WS_SYSMENU = 0x80000;
[System.Runtime.InteropServices.DllImport("user32.dll", SetLastError = true)]
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
private void Window_Loaded(object sender, RoutedEventArgs e)
{
var hwnd = new System.Windows.Interop.WindowInteropHelper(this).Handle;
SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_SYSMENU);
}

private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if (ctype < 1)
e.Cancel = true;
}

private void btnSave_MouseUp(object sender, MouseButtonEventArgs e)
{
try
{
ctype = 1;

}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "提示", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
private void btnCancel_MouseUp(object sender, MouseButtonEventArgs e)
{
Environment.Exit(0);
}

时间: 2024-10-13 05:00:54

去掉关闭按钮同时禁用alt+f4进行关闭的相关文章

Winform窗体屏蔽Alt+F4强制关闭

1 /// <summary> 2 /// 窗体屏蔽 ALT+F4组合键强制关闭 3 /// </summary> 4 protected override CreateParams CreateParams 5 { 6 get 7 { 8 const int CS_NOCLOSE = 0x200; 9 CreateParams cp = base.CreateParams; 10 cp.ClassStyle = cp.ClassStyle | CS_NOCLOSE; 11 ret

C#屏蔽Alt+F4,解决Alt+F4关闭窗体时对话框NO后,线程不退出问题

//1.将窗体的属性KeyPrieview设置为true //keypreview属性为true的时候,就可以响应键盘事件v //2.在窗体KeyDown事件中加如下代码 private void Form1_KeyDown(object sender, KeyEventArgs e) { if( (e.KeyCode == Keys.F4)&&(e.Alt==true)) //屏蔽ALT+F4 { e.Handled = true; } } //e.Handled属性:获取或设置一个值,

Winfrom 屏蔽Alt+F4

/// <summary> /// 屏蔽Alt+F4 /// </summary> /// <param name="m">要处理的 Windows </param> protected override void WndProc(ref Message m) { const int WM_SYSCOMMAND = 0x0112; const int SC_CLOSE = 0xF060; if (m.Msg == WM_SYSCOMMAN

Delphi 如何屏蔽Alt F4

系统命令消息就是这样屏蔽,哈哈. procedure WMSysCommand(var Msg: TMessage);message WM_SYSCOMMAND; procedure tform1.WMSysCommand(var Msg: TMessage); begin if Msg.wParam <> SC_CLOSE then inherited; end; Delphi 如何屏蔽Alt F4

tera term 禁用ALT键

Setup -> Keyboard对话框中将 Meta key改成: left tera term 禁用ALT键

C# Winform 实现屏蔽键盘的win和alt+F4的实现代码

最近在做一个恶搞程序,就是打开后,程序获得桌面的截图然后,然后全屏显示在屏幕上,用户此时则不能进行任何操作. 此时希望用户不能通过键盘alt+F4来结束程序及通过Win的组合键对窗口进行操作.我在网上搜索了一下,采用全局键盘钩子的方法可以做到屏蔽用户对键盘的操作..以下为相关代码,用到了Form1_load事件和Form1_FormClosing事件: using System; using System.Collections.Generic; using System.ComponentMo

如何禁用ECSHOP缓存,如何关闭ECSHOP缓存

熟悉ECSHOP的老站长们都知道,ECSHOP是有缓存机制的. ECSHOP的缓存机制从一定程度上可以减少ECSHOP反复读取数据库的几率,从而一定程度上降低服务器负担,提高访问速度. 但是启用缓存机制,对一些新手站长也有不利的地方.我就遇到很多新手站长经常问,我明明修改了什么什么,为什么前台就没变化呢,这就是缓存在作怪,一般到后台清除缓存就可以了. 鉴于上述原因,有一些站长就在想能不能"禁用ECSHOP缓存,关闭ECSHOP缓存"呢?答案是肯定的. 下面就来讲一讲"如何禁用

wpf阻止键盘快捷键alt+space,alt+F4

原文:wpf阻止键盘快捷键alt+space,alt+F4 /// <summary>        /// 阻止 alt+f4和alt+space 按键        /// </summary>        /// <param name="e"></param>        protected override void OnKeyDown(System.Windows.Input.KeyEventArgs e)       

BootStrap 模态框禁用ESC关闭、禁用点击空白处关闭

<!--Edit Model--> <div id="AddProjectModel" class="modal inmodal" tabindex="-1" role="dialog" aria-hidden="true" data-keyboard="false"> </div> data-keyboard=false,禁用按ESC关闭,data-