I am trying to copy the image to clipboard. I am using the following code.
void test::OnEditCopyImage()
{
bool clipboardAcceptedData = true;
COXScreenGrabber ScreenGrabber;
RECT rect;
mainFrame->SetWindowPos(&CWnd::wndTopMost,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_SHOWWINDOW);
GetParent()->GetWindowRect(&rect);
ScreenGrabber.GrabRectangle(rect);
COXDIB* pDib = ScreenGrabber.GetGrabDIB();
VERIFY(OpenClipboard());
VERIFY(EmptyClipboard()):
if (::SetClipboardData(CF_DIB, pDib->m_hDIB)==NULL)
{
AfxMessageBox(IDS_STRING123);
clipboardAcceptedData = false;
}
CloseClipboard();
if ( clipboardAcceptedData == true )
pDib->m_hDIB = NULL;
}
But the selected menu item 'COPY Image to ClipBoard' also appears on the image. It happens only when I run the program on Windows Vista/Windows 7. Works fine on WINDOWS XP. Can anyone help?