Read notes-clipboard for Windows programming.

Source: Internet
Author: User

Case idm_edit_paste: openclipboard (hwnd); // open the clipboard if (hglobal = getclipboarddata (cf_tchar) // obtain the clipboard memory handle {pglobal = globallock (hglobal); // lock the handle, obtain the memory pointer if (ptext) {free (ptext); ptext = NULL;} ptext = malloc (globalsize (hglobal); // copy the memory data lstrcpy (ptext, pglobal ); invalidaterect (hwnd, null, true);} closeclipboard (); // close the clipboard return 0; Case idm_edit_cut: Case idm_edit_copy: If (! Ptext) return 0; hglobal = globalalloc (ghnd | gmem_share, (lstrlen (ptext) + 1) * sizeof (tchar); pglobal = globallock (hglobal); lstrcpy (pglobal, ptext); globalunlock (hglobal); openclipboard (hwnd); // open the clipboard emptyclipboard (); // clear the clipboard setclipboarddata (cf_tchar, hglobal ); // set the memory handle closeclipboard (); // close the clipboard if (loword (wparam) = idm_edit_copy) return 0; // fall through for idm_edit_cut

I. Clipboard principle:

* Only one data item can be retained for the same type of data in the clipboard.

* The Clipboard contains a handle pointing to the copy and cut memory.

Copy & cut:

Obtain the handle pointing to the memory that stores the copy and cut data.

Open clipboard

Clear clipboard

Set memory handle

Close clipboard

Paste:

Open clipboard

Obtains the handle pointing to the memory that stores the copied and cut data.

Lock the handle to obtain the memory pointer

Copy memory data for corresponding processing

Close clipboard

 

Ii. Other functions:

Isclipboardformatavailable () determines whether the content in the clipboard is determined by the content.

Enumclipboardformats // returns a value for each format in the clipboard

Countclipboardformats // number of different formats

Getclipboardowner // get the clipboard owner

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.