我有一个用户控件
public partial class UserControl1 : UserControl, IMessageFilter
{
public UserControl1()
{
InitializeComponent();
Application.AddMessageFilter(this);
}
public bool PreFilterMessage(ref Message m)
{
var mouseLocation = Cursor.Position;
if (Bounds.Contains(PointToClient(mouseLocation)))
{
bool aBool = true;//breakpoint
bool two = aBool;//just assignment so compiler doesn't optimize my bool out
}
if (m.Msg != 0x20a) // Scrolling Message
{
return false;//ignore message
}
return false;
}
}
当我漂浮在包含在父窗体中的用户控件上时,没有命中断点。断点在附近被击中,但我可以在用户控件内的实际文本框中而不被击中。如何准确确定我是否在此用户控件的范围内?
FWIW,我有两台显示器。我使用的显示器似乎没有什么区别。