/// <summary>
/// 删除系统菜单
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void window_SourceInitialized(object sender, EventArgs e)
{
var window = (Window)sender;
var helper = new WindowInteropHelper(window);
IntPtr windowHandle = helper.Handle; //Get the handle of this window
IntPtr hmenu = GetSystemMenu(windowHandle, 0);
DestroyMenu(hmenu);
hmenu = IntPtr.Zero;
}
[DllImport("user32.dll", EntryPoint = "GetSystemMenu")]
private static extern IntPtr GetSystemMenu(IntPtr hwnd, int revert);
[DllImport("user32.dll", EntryPoint = "GetMenuItemCount")]
private static extern int GetMenuItemCount(IntPtr hmenu);
[DllImport("user32.dll", EntryPoint = "DestroyMenu")]
private static extern bool DestroyMenu(IntPtr hmenu);
private const int MF_BYPOSITION = 0x0400;
private const int MF_DISABLED = 0x0002;
wpf 删除系统自带右键菜单
原创
©著作权归作者所有:来自51CTO博客作者lreach的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:wpf image 打印(备忘)
下一篇:hwndhost
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
增加系统右键菜单
本文介绍添加系统右键菜单,效果如下图:原理很简单就是给注册表添加值
Tools 右键菜单 文件目录 二维码 -
h5 在iOS端 显示alert
html5给大多数元素都增加了contentEditable属性,如果给某元素设置属性 contentEditable = "true",那么该元素就会进入可编辑状态,即浏览器会允许用户直接编辑该元素内容。 html:<div class="wraper"> <div contenteditable="true"> <
h5 在iOS端 显示alert html5 contentEditable 可编辑 换行符