public partial class ComEdit:Combobox,IMessageFilter
{
public ComEdit()
{
InitializeComponent();
this.SetStyle(ControlStyles.DoubleBuffer, true);
Application.AddMessageFilter(this);
this.MouseEnter += ComEdit_MouseEnter;
this.MouseLeave += ComEdit_MouseLeave;
}
#region 禁用鼠标滚轮事件
///
/// 判断鼠标是否在控件上
///
bool IsFoused { get; set; } = false;
private void ComEdit_MouseLeave(object sender, EventArgs e)
{
IsFoused = false;
}
private void ComEdit_MouseEnter(object sender, EventArgs e)
{
IsFoused = true;
}
public bool PreFilterMessage(ref Message m)
{
if (IsFoused)
{
if (m.Msg == 0x020A)
return true;
return false;
}
return false;
}
#endregion
}
最后
以上就是细心月亮最近收集整理的关于禁用鼠标滚轮事件(对单个下拉控件,不影响其他控件的滚轮事件)的全部内容,更多相关禁用鼠标滚轮事件(对单个下拉控件,不影响其他控件内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复