110,539
社区成员
发帖
与我相关
我的任务
分享
Public enum KeyModifiers{None=0,Alt=1,Control=2,Shift=4,Windows=8}
//注册系统热键:
[DllImport(“user32.dll”,SetLastError=true)] public static extern bool RegisterHotKey(
IntPtr hwnd, int id, KeyModifiers fsModifiers,
Keys vk
);
//释放:
[DllImport(“user32.dll”,SetLastError=true)] public static extern bool UnregisterHotKey(IntPtr hwnd,int id);
//定义快捷键(ctrl+S):
Bool success=RegisterHotKey(Handle,100,KeyModifiers.Control,Keys.S);
Protected override void WndProc(ref Message m)
{ const int WM_HOTKEY=0x0312;
If(m.Msg==WM_HOTKEY)
{ProcessHotKey(); //热键处理程序,连到button.click就可以了
}
Base.WndProc(ref m);
}
this.AddOwnedForm(ZBXTForm);
ZBXTForm.KeyPreview=true;
ZBXTForm.ShowDialog();
this.ActivateMdiChild(frmChild);