C # analog PRTSCN for screenshot prep-clipboard operations

Source: Internet
Author: User

The Clipboard is one of the most common features of the Windows operating system, which is used to pass data from one application to another, such as text, images, or even program objects. However, the Clipboard also has a limit, it can only point to a piece of content at a certain time, each subsequent copy of the content will replace the previous content. To manipulate the Clipboard (including read and write content) in C #, you need to use the System.Windows.Forms.Clipboard class.

Clipboard class:
Provides methods for placing data on the system Clipboard and retrieving data from it, and this class cannot be inherited.
Namespaces: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Syntax: public sealed class Clipboard

Clipboard::getdataobject Method:
Grammar:

public:staticGetDataObject()

return value
Type: System.windows.forms::idataobject
A idataobject that represents the current data in the system Clipboard, or a null reference if there is no data in the Clipboard (Nothing in Visual Basic).
Because the data type of the object returned from the Clipboard can be different, this method returns the data in IDataObject. You can then use the IDataObject interface method to extract data with the correct data type.

Clipboard::containsimage Method:
Indicates whether there is a Bitmap format or data that can be converted to this format in the Clipboard
Use this method to determine whether the Clipboard contains image data before retrieving the image data using the GetImage method.
Grammar:

public:staticboolContainsImage()

return value
Type: System::boolean
True if image data is present in the Clipboard; otherwise, false.

Clipboard::getimage Method:
Indicates whether the Clipboard exists
Before you use this method to retrieve image data, use the ContainsImage method to determine whether the Clipboard contains image data.
Grammar:

public:staticGetImage()

return value
Type: System.drawing::image
An image that represents the Clipboard image data, or a null reference if the Clipboard does not contain any bitmap format or data that can be converted to that format.

public System.Drawing.Image SwapClipboardImage(    System.Drawing.Image replacementImage){    System.Drawing.Image returnImage = null;    if (Clipboard.ContainsImage())    {        returnImage = Clipboard.GetImage();        Clipboard.SetImage(replacementImage);    }    return returnImage;}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

C # analog PRTSCN for screenshot prep-clipboard operations

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.