void test::OnEditCopyImage() // Copy to the Clipboard. { bool clipboardAcceptedData = true; // Capture the window to a bitmap. COXScreenGrabber ScreenGrabber; RECT rect; mainFrame->SetWindowPos(&CWnd::wndTopMost,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_SHOWWINDOW); GetParent()->GetWindowRect(&rect); // get the rect of the frame, not just the graph ScreenGrabber.GrabRectangle(rect); COXDIB* pDib = ScreenGrabber.GetGrabDIB(); VERIFY(OpenClipboard()); VERIFY(EmptyClipboard()):// Remove the current Clipboard contents & reassign ownership. if (::SetClipboardData(CF_DIB, pDib->m_hDIB)==NULL) { AfxMessageBox(IDS_STRING123); clipboardAcceptedData = false; } CloseClipboard(); //keep the bitmap 'alive', the clipboard now owns it. // Set the handle to NULL so that the destructor does not free the memory. if ( clipboardAcceptedData == true ) pDib->m_hDIB = NULL; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)