When you write a document that helps explain the class, the captured picture is more intuitive and more user-friendly if it has a pointer to the mouse shape. Now let's talk about how to include the mouse pointer shape in.
Add Structure Cursorinfo:
[StructLayout (layoutkind.sequential)] struct Cursorinfo {public int cbsize; public int flags; Public IntPtr hcursor; Public point Ptscreenpos; }
Declaration API:
[DllImport ("User32.dll")] static extern bool Getcursorinfo (out Cursorinfo PCI);
To define an enumeration value:
Private Const int cursor_showing = 0x00000001;
To add a method:
<summary>////Draw the mouse pointer to the screen////</summary>// <param name= "G" ></param> private void Drawcursorimagetoscreenimage (ref Graphics g) { if (!this. Iscutcursor) {return;} Cursorinfo Vcurosrinfo; Vcurosrinfo.cbsize = Marshal.SizeOf (typeof (Cursorinfo)); Getcursorinfo (out vcurosrinfo); if ((Vcurosrinfo.flags & cursor_showing)! = cursor_showing) return; Cursor vcursor = new cursor (vcurosrinfo.hcursor); Rectangle vrectangle = new Rectangle (new Point (Vcurosrinfo.ptscreenpos.x-vcursor.hotspot.x, VCUROSRINFO.PTSCREENPOS.Y-VCURSOR.HOTSPOT.Y), vcursor.size); Vcursor.draw (g, Vrectangle); }
To add a method call:
OK, check it out again!