Change the mouse pointer shape using C #

Source: Internet
Author: User

1. Use the MouseMove event in an untitled form to determine if the mouse coordinates reach the edge of the form, and if so, change the mouse pointer to a two-headed arrow that resizes the form. 

private void Form1_mousemove (object sender, System.Windows.Forms.MouseEventArgs e)
{
if (0 = = e.x)
{
This. Cursor = Cursors.sizewe;
}

Change it to this, it's strange (can't be written: E. X >= this. Width)
else if (e.x >= this. WIDTH-2)

{
This. Cursor = Cursors.sizewe;
}
Else
{
This. Cursor = Cursors.Default;
}
}

 2. However, the cursor class provided by C#.net can only do transformations between the cursor shapes provided by Windows, and the cursor class does not seem to support animations and multi-color files. I want to use my own bitmap file as the cursor, how should I do?Scenario: Use a mouse file to define your own mouse pointer. cursor.current=new Cursor (@ "C:\my.cur");or:cursor cur=new Cursor (@ "C:\my.cur");This . Cursor = Cur;by Adding the above code to the form's constructor, you can change the mouse pointer shape.
My.cur is a mouse bitmap file, the mouse picture directly as a file into the project, in the project to select the added files after the properties, modify the generated attribute value for embedded resources, so you can compile into the EXE to take.

Change the mouse pointer shape using C #

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.