C # control Mouse messages

Source: Internet
Author: User
Tags touch

My program does not want the mouse to touch the listbox on the form, what should I do? or let the mouse not touch the entire form, you can only click the Close button to close the form can also be. In there is simply let the mouse malfunction, set a keyboard shutdown program

You can add the message to the application and processing, so that you can control the mouse message function, such as the following code:

Class Msgfilter:imessagefilter
{
public bool Prefiltermessage (ref message M)
{
if (m.msg = = 0x100 && M.wparam = = (INTPTR) 0x11)//(Wm_rbuttondown)
{
This returns true to indicate that the application is not processing this message and
Make this message invalid and you can find additional mouse messages to add here.
return true;
}
}
}
<summary>
The main entry point for the application.
</summary>
[STAThread]
static void Main ()
{
Application.enablevisualstyles ();
Msgfilter ms=new Msgfilter ()//Add Message Filter
Application.addmessagefilter (MS);
Application.setcompatibletextrenderingdefault (FALSE);
Application.Run (New Form1 ());
Application.removemessagefilter (MS);//Remove Message Filter
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.