How to change the mouse cursor into a custom one when working with Windows Forms applications?

前端 未结 4 610
栀梦
栀梦 2020-12-28 12:36

In a UserControl I want to change the mouse cursor from the arrow, to a hand icon.
What I currently do is this:

this.Cursor = Cursors.Hand;
         


        
4条回答
  •  感动是毒
    2020-12-28 13:08

    I tested this method. It's OK. This is my apply:

        [System.Runtime.InteropServices.DllImport("user32.dll")]
        public static extern IntPtr LoadCursorFromFile(string fileName);
        Cursor myCursor;
        private void tsbtn_ZoomIn_Click(object sender, EventArgs e)
        {
            IntPtr handle = LoadCursorFromFile("view_zoom_in.cur");
            myCursor = new Cursor(handle);
            zg1.Cursor = myCursor;
        }
    

提交回复
热议问题