C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,411 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
how do I detect left mouse down for .NET 6.0
A way is with IMessageFilter, like :
public const int WM_LBUTTONDOWN = 0x0201;
public const int WM_LBUTTONUP = 0x0202;
public Form1()
{
InitializeComponent();
CMessageFilter mf = new CMessageFilter();
Application.AddMessageFilter(mf);
}
public class CMessageFilter : IMessageFilter
{
public bool PreFilterMessage(ref Message m)
{
if (m.Msg == WM_LBUTTONDOWN)
Console.Beep(1000, 10);
return false;
}
}
if you are working with windows application,
create mouseDown/mouseUp/mouseClick or Click event for control you wanted to use on
,,then check if(e.Button==MouseButton.Left)