注册系统热键
来源:互联网 发布:ntfs for mac 激活 编辑:程序博客网 时间:2024/05/16 15:14
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace HotKeyApp
...{
public partial class Form1 : Form
...{
[System.Runtime.InteropServices.DllImport("user32.dll")] //申明API函数
public static extern bool RegisterHotKey(
IntPtr hWnd, // handle to window
int id, // hot key identifier
uint fsModifiers, // key-modifier options
Keys vk // virtual-key code
);
[System.Runtime.InteropServices.DllImport("user32.dll")] //申明API函数
public static extern bool UnregisterHotKey(
IntPtr hWnd, // handle to window
int id // hot key identifier
);
public enum KeyModifiers
...{
None = 0,
Alt = 1,
Control = 2,
Shift = 4,
Windows = 8
}
public Form1()
...{
InitializeComponent();
RegisterHotKey(Handle, 100, 2, Keys.U);
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
...{
UnregisterHotKey(Handle, 100); //卸载第1个快捷键
}
protected override void WndProc(ref Message m)//监视Windows消息
...{
const int WM_HOTKEY = 0x0312; //如果m.Msg的值为0x0312那么表示用户按下了热键
switch (m.Msg)
...{
case WM_HOTKEY:
ProcessHotkey(m); //按下热键时调用ProcessHotkey()函数
break;
}
base.WndProc(ref m); //将系统消息传递自父类的WndProc
}
private void ProcessHotkey(Message m)
...{
IntPtr id = m.WParam; //IntPtr用于表示指针或句柄的平台特定类型
//MessageBox.Show(id.ToString());
string sid = id.ToString();
switch (sid)
...{
case "100": this.Show(); break; //
}
}
private void button1_Click(object sender, EventArgs e)
...{
this.Hide();
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace HotKeyApp
...{
public partial class Form1 : Form
...{
[System.Runtime.InteropServices.DllImport("user32.dll")] //申明API函数
public static extern bool RegisterHotKey(
IntPtr hWnd, // handle to window
int id, // hot key identifier
uint fsModifiers, // key-modifier options
Keys vk // virtual-key code
);
[System.Runtime.InteropServices.DllImport("user32.dll")] //申明API函数
public static extern bool UnregisterHotKey(
IntPtr hWnd, // handle to window
int id // hot key identifier
);
public enum KeyModifiers
...{
None = 0,
Alt = 1,
Control = 2,
Shift = 4,
Windows = 8
}
public Form1()
...{
InitializeComponent();
RegisterHotKey(Handle, 100, 2, Keys.U);
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
...{
UnregisterHotKey(Handle, 100); //卸载第1个快捷键
}
protected override void WndProc(ref Message m)//监视Windows消息
...{
const int WM_HOTKEY = 0x0312; //如果m.Msg的值为0x0312那么表示用户按下了热键
switch (m.Msg)
...{
case WM_HOTKEY:
ProcessHotkey(m); //按下热键时调用ProcessHotkey()函数
break;
}
base.WndProc(ref m); //将系统消息传递自父类的WndProc
}
private void ProcessHotkey(Message m)
...{
IntPtr id = m.WParam; //IntPtr用于表示指针或句柄的平台特定类型
//MessageBox.Show(id.ToString());
string sid = id.ToString();
switch (sid)
...{
case "100": this.Show(); break; //
}
}
private void button1_Click(object sender, EventArgs e)
...{
this.Hide();
}
}
}
- 如何注册系统热键
- 注册系统热键
- 注册系统热键
- C#注册系统热键
- 注册系统热键
- 注册系统热键
- C# 注册系统热键
- 注册系统热键
- 注册系统热键 RegisterHotKey()
- C# 注册系统热键
- C# 注册系统热键
- 注册系统热键
- DELPHI如何注册系统热键
- VC系统热键的注册
- VC系统热键的注册
- vc 如何注册系统热键
- 用DELPHI如何注册系统热键
- vc 如何注册多个系统热键
- 女性如何理解男人的性需求? 男性的性表达
- MFC如何实现com接口
- 中文真伟大!竟然有只能看不能读的文章
- html特殊字符转换(java)
- 经济学原理
- 注册系统热键
- JSP中的request对象
- struts必须有的包
- tomcat的配置支持多个网站
- VS插件开发(1 菜单)
- 安装Visual Studio补丁遇到错误1718的解决方法
- gcc
- 加资源的JASS代码
- makefile