给窗体的任务栏右键菜单增加项目
2009-06-10 21:57
369 查看
给窗体的任务栏右键菜单增加项目
[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);
// 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);
// 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#增加任务栏系统右键菜单项目
- 为右键增加菜单项目
- C# 无边框窗体的移动,任务栏右键菜单,调整大小
- Delphi中无边框窗体应用程序使任务栏右键菜单有效的方法
- C#给任务栏右键菜单增加按钮
- 鼠标右键新建增加菜单项目
- WinForm 不规则窗体添加任务栏右键菜单
- 如何去除WIN7任务栏项目上右键菜单中的最近访问一栏
- 给无边框窗体添加任务栏右键菜单
- Delphi中无边框窗体应用程序使任务栏右键菜单有效的方法
- C# 无边框窗体的移动,任务栏右键菜单,调整大小
- C#无边框窗体在任务栏右键菜单
- C#TreeView窗体版点击右键弹出菜单+右键获取信息
- Linux上Eclipse项目右键菜单没有Maven
- ubuntu14.04,如何使用鼠标右键菜单在shell中打开选择项目?
- GridView控件(九)——给数据行增加右键菜单
- Delphi 最小化程序到任务栏托盘 增加右键PopMenu
- 怎么实现“鼠标穿透”,即鼠标对窗体失去作用,对着它点右键要出现WINDOWS的桌面右菜单
- 右键菜单增加DOS选项
- FckEditor添加右键菜单;增加编辑区右键图片删除功能(asp.net )(二)