C#给任务栏右键菜单增加按钮
2008-07-03 17:19
357 查看
using System.Runtime.InteropServices;
[DllImport("user32.dll")]
private static extern int GetSystemMenu(int hwnd, int bRevert);
[DllImport("user32.dll")]
private static extern int AppendMenu(
int hMenu, int Flagsw, int IDNewItem, string lpNewItem);
private void SetupSystemMenu()
...{
// get handle to system menu
int menu = GetSystemMenu(this.Handle.ToInt32(), 0);
// add a separator
AppendMenu(menu, 0xA00, 0, null);
// add an item with a unique ID
AppendMenu(menu, 0, 1234, "跳至URL");
AppendMenu(menu, 0, 1235, "关于HTML帮助");
}
protected override void WndProc(ref Message m)
...{
base.WndProc(ref m);
// WM_SYSCOMMAND is 0x112
if (m.Msg == 0x112)
...{
// check for my new menu item ID
if (m.WParam.ToInt32() == 1234)
...{
// show About box here...
MessageBox.Show("Btn One");
}
if (m.WParam.ToInt32() == 1235)
...{
// show About box here...
MessageBox.Show("Btn Two");
}
}
}
[DllImport("user32.dll")]
private static extern int GetSystemMenu(int hwnd, int bRevert);
[DllImport("user32.dll")]
private static extern int AppendMenu(
int hMenu, int Flagsw, int IDNewItem, string lpNewItem);
private void SetupSystemMenu()
...{
// get handle to system menu
int menu = GetSystemMenu(this.Handle.ToInt32(), 0);
// add a separator
AppendMenu(menu, 0xA00, 0, null);
// add an item with a unique ID
AppendMenu(menu, 0, 1234, "跳至URL");
AppendMenu(menu, 0, 1235, "关于HTML帮助");
}
protected override void WndProc(ref Message m)
...{
base.WndProc(ref m);
// WM_SYSCOMMAND is 0x112
if (m.Msg == 0x112)
...{
// check for my new menu item ID
if (m.WParam.ToInt32() == 1234)
...{
// show About box here...
MessageBox.Show("Btn One");
}
if (m.WParam.ToInt32() == 1235)
...{
// show About box here...
MessageBox.Show("Btn Two");
}
}
}
相关文章推荐
- C#增加任务栏系统右键菜单项目
- 怎么在IE右键菜单中添加菜单项及怎么添加IE任务栏按钮
- 如何在IE右键菜单中添加菜单项以及如何添加IE任务栏按钮
- c#中添加Windows任务栏右键菜单
- C# 无边框窗体的移动,任务栏右键菜单,调整大小
- C# 无边框窗体的移动,任务栏右键菜单,调整大小
- C#无边框窗体在任务栏右键菜单
- 给窗体的任务栏右键菜单增加项目
- 如何在IE右键菜单中添加菜单项以及如何添加IE任务栏按钮
- C#用鼠标钩子屏蔽任务栏右键弹出菜单
- C#用鼠标钩子屏蔽任务栏右键弹出菜单
- C# 创建右键菜单和编程
- C#实现窗体最小化时存至系统托盘,并为notifyicon添加右键菜单
- (C#)Windows Shell 外壳编程系列7 - ContextMenu 注册文件右键菜单
- C# winform ListView 的右键菜单的下级菜单的选项视情况禁用方法
- C# 树的不同节点显示不同的右键菜单
- C#开发微信门户及应用(15)-微信菜单增加扫一扫、发图片、发地理位置功能
- [转]C#创建右键菜单
- 任务栏右键菜单关闭程序发送的消息
- 增加Win8任务栏图标右键的常用列表数目