Use C # to achieve screenshot function (3) (similar to QQ screenshot)

Source: Internet
Author: User

2, create a screenshot of the main window

Core class MyRectangle has been completed, the rest of the work is to use the modified class to achieve the desired screenshot function.

Use VS2005 to create a new project named Screencutter. Name the main window mainform, create a new window named Screenbody, set its ShowInTaskbar property to False,topmost property set to None for the True,formborderstyle property, Add a Panel control Panel1 on the Screenbody, set the BackColor property to blue, add the corresponding number of labels to panel1, such as Labellocation, Labelwidth, Labelheight, and so on. Used to indicate the current selection position and size, the PANEL1 final style is:

The reference namespace for modifying Screenbody is:

using System;
using System.Drawing;
using System.Windows.Forms;
在ScreenBody类中添加如下私有成员:
    private Graphics MainPainter; //the main painter
    private bool isDowned; //check whether the mouse is down
    private bool RectReady; //check whether the rectangle is finished
    private Image baseImage; //the back ground of the screen
    private Point moveModeDownPoint; //the mouse location when you move the rectangle
    private MyRectangle myRectangle; //the rectangle
    private bool moveMode; //check whether the rectangle is on move mode or not
    private bool changeSizeMode; //check whether the rectangle is on change size mode or not

To modify the Screenbody constructor:

public ScreenBody()
    {
      InitializeComponent();
      panel1.Location = new Point(this.Left, this.Top);
      myRectangle = new MyRectangle();
      moveModeDownPoint = new Point();
      this.Cursor = myRectangle.MyCursor;
    }

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.