捕获鼠标触碰win窗体的标题栏
本文关键字:窗体 标题栏 win 鼠标 | 更新日期: 2023-09-27 18:03:08
我得到了一些技巧来捕获鼠标触摸标题栏,但是当我将鼠标放在标题栏上时,例程反复着火。下面是例程
protected override void WndProc(ref Message m)
{
if (m.Msg == 0xA0) // WM_NCMOUSEMOVE
{
listBox1.Items.Add("mouse move on title bar");
}
else if (m.Msg == 0x2A2) // WM_NCMOUSELEAVE
{
listBox1.Items.Add("mouse leave from title bar");
}
base.WndProc(ref m);
}
有谁能告诉我任何技巧,因为WndProc在鼠标触摸标题栏时只触发一次,而不是反复触发。由于
你在找这个吗?我正在使用flag.
控制列表框中项目的添加。private bool insideTitleBar = false;
private bool outsideTitleBar = false;
protected override void WndProc(ref Message m)
{
if (m.Msg == 0xA0) // WM_NCMOUSEMOVE
{
if(!insideTitleBar)
{
listBox1.Items.Add("mouse move on title bar");
insideTitleBar = true;
outsideTitleBar = false;
}
}
else if (m.Msg == 0x2A2) // WM_NCMOUSELEAVE
{
if(!outsideTitleBar)
{
listBox1.Items.Add("mouse leave from title bar");
outsideTitleBar = true;
insideTitleBar = false;
}
}
base.WndProc(ref m);
}