C # Development Example-Custom screenshot tool (10) Include the mouse pointer shape in the screenshot

Source: Internet
Author: User
Tags cursorinfo
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!

Related Article

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.