MouseWheeMsg.cs
上传用户:fan366
上传日期:2022-07-21
资源大小:406k
文件大小:2k
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Windows.Forms;
- namespace OnePhoto
- {
- public delegate void MouseWheelHandler(object sender, bool isDelta);
- public class MouseWheeMsg:System.Windows.Forms.IMessageFilter
- {
- public event MouseWheelHandler MouseWheel;
- protected virtual void OnMouseWheel(bool isDelta)
- {
- if (MouseWheel != null)
- MouseWheel(this, isDelta);
- }// end viod
- private const int WM_MOUSEWHEEL = 0x020A;
- /// <summary>
- /// 定义句柄
- /// </summary>
- private bool m_HandleType;
- /// <summary>
- /// 设置是窗体句柄 还是控件句柄
- /// </summary>
- public bool SetHandleType
- {
- set
- {
- this.m_HandleType = value;
- }
- }// end Form;
- public MouseWheeMsg()
- {
- //
- // TODO: 在此处添加构造函数逻辑
- //
- this.m_HandleType = true;
- }
- /// <summary>
- /// 如果键入
- /// </summary>
- /// <param name="m"></param>
- /// <returns></returns>
- public bool PreFilterMessage(ref Message m)
- {
- switch (m.Msg)
- {
- case WM_MOUSEWHEEL:
- if (this.m_HandleType)
- {
- //Type mytype = this.m_MouseEvent.GetType();
- //this.m_MouseEvent = (System.Windows.Forms.MouseEventArgs)m.GetLParam(mytype);
- if (m.WParam.ToInt32() > 0)
- {
- OnMouseWheel(true);
- }// end if
- else
- {
- OnMouseWheel(false);
- }// end if
- return true;
- }
- break;
- }// end switch
- return false;
- }
- }
- }