Copy the specified area of the window pointed to by pwnd to the clipboard.

Source: Internet
Author: User

 

// Copy the lpsrcrect of the window pointed to by pwnd to the clipboard // run this program, you can open the drawing and paste the test copyscreentoclipboard (cwnd * pwnd, crect * lpsrcrect) {If (! Iswindow (pwnd-> getsafehwnd () {afxmessagebox ("Invalid Window handle"); Return (false);} // first, determine the update region and select ITIF (! Pwnd-> openclipboard () {afxmessagebox ("Clipboard cannot be opened"); Return (false) ;}// remove the current clipboard contentsif (! Emptyclipboard () {afxmessagebox ("failed to clear the Clipboard"); Return (false);} // int width = lpsrcrect-> width (); int Height = lpsrcrect-> height (); CDC * PDC = pwnd-> getdc (); // create a memory dccdc memdc; memdc. createcompatibledc (PDC); // create the bitmap cbitmap m_bitmap; m_bitmap.createcompatiblebitmap (PDC, width, height); // select the bitmap memdc. selectObject (& m_bitmap); // copy memdc. bitblt (0, 0, width, height, PDC, 0, 0, srccopy); // copy to the clipboard setclipboarddata (cf_bitmap, m_bitmap.m_hobject); // close the clipboard closeclipboard (); return (true );}

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.