C#获取系统鼠标指针

系统设置了鼠标指针的样式 可以通过下面的方法设置程序的鼠标指针样式

 

 

[DllImport("user32.dll", EntryPoint = "SetCursor")] public static extern IntPtr SetCursor(IntPtr hCursor); /// <summary> /// 获取鼠标句柄 /// </summary> /// <param name="hInstance">IntPtr.Zero</param> /// <param name="cursor">样式</param> /// <returns></returns> [DllImport("User32.dll", CharSet = CharSet.Auto)] public static extern IntPtr LoadCursor(IntPtr hInstance, CursorType cursor); public enum CursorType : uint { IDC_ARROW = 32512U, IDC_IBEAM = 32513U, IDC_WAIT = 32514U, IDC_CROSS = 32515U, IDC_UPARROW = 32516U, IDC_SIZE = 32640U, IDC_ICON = 32641U, IDC_SIZENWSE = 32642U, IDC_SIZENESW = 32643U, IDC_SIZEWE = 32644U, IDC_SIZENS = 32645U, IDC_SIZEALL = 32646U, IDC_NO = 32648U, IDC_HAND = 32649U, IDC_APPSTARTING = 32650U, IDC_HELP = 32651U } private void Form1_MouseMove(object sender, MouseEventArgs e) { IntPtr _HandCursorIntPrt = LoadCursor(IntPtr.Zero, CursorType.IDC_HAND); SetCursor(_HandCursorIntPrt); }

你可能感兴趣的:(object,C#,user)