12345678910111213141516171819202122232425262728 |
- using System.Windows.Forms;
- using UAS_PLCDataReader.Entity;
- namespace UAS_PLCDataReader.PublicMethod
- {
- /// <summary>
- /// Author zhangz 2016/12/30
- /// 全局事件处理,通过句柄获取触发事件的控件
- /// 结合捕获的全局的键盘事件来验证用户进行的操作
- /// </summary>
- class GlobalEventsHandler : IMessageFilter
- {
- //鼠标左键点击
- public const int WM_LBUTTONDOWN = 0x0201;
- //键盘敲击事件
- public const int WM_KEYDOWN = 0x100;
- public bool PreFilterMessage(ref Message m)
- {
- Control c = Control.FromHandle(m.HWnd);
- if (m.Msg == WM_LBUTTONDOWN && c.GetType().ToString().ToUpper().Contains("BUTTON"))
- {
- LogicHandler.DoCommandLog(User.UserCode, c.Parent.Text, "点击【" + c.Text + "】按钮");
- }
- return false;
- }
- }
- }
|