how to copy the bitmap data to clipboard?
-
at first, please visit this topic. http://www.codeproject.com/bitmap/drawing2bitmap.asp and my question is below. how to copy the bitmap data to clipboard? Thank you in advance.
-
at first, please visit this topic. http://www.codeproject.com/bitmap/drawing2bitmap.asp and my question is below. how to copy the bitmap data to clipboard? Thank you in advance.
Check out the
SetClipboardData
function. To but a bitmap on the clipboard useCF_BITMAP
,CF_DIB
,CF_DIBV5
orCF_DIBV5
or to put a file useCF_HDROP
.Steve
-
Check out the
SetClipboardData
function. To but a bitmap on the clipboard useCF_BITMAP
,CF_DIB
,CF_DIBV5
orCF_DIBV5
or to put a file useCF_HDROP
.Steve
Thank you. yes, i already try this function and COleDataSource::SetClipboard(). but they are not work. and below is my code.
if ( OpenClipboard() ) { EmptyClipboard(); SetClipboardData(CF_BITMAP, m_hDrawingSurface); CloseClipboard(); }
code using oleCOleDataSource* pDataSource = new COleDataSource; TRY { // Create a shared file and associate a CArchive with it CSharedFile file; CArchive ar(&file,CArchive::store); BITMAPFILEHEADER bmfh; int nBitsOffset = sizeof(BITMAPFILEHEADER) + m_bmpInfoHeader.biSize; LONG lImageSize = m_bmpInfoHeader.biSizeImage; LONG lFileSize = nBitsOffset + lImageSize; bmfh.bfType = 'B'+('M'<<8); bmfh.bfOffBits = nBitsOffset; bmfh.bfSize = lFileSize; bmfh.bfReserved1 = bmfh.bfReserved2 = 0; //Write the bitmap file header ar.Write(&bmfh, sizeof(BITMAPFILEHEADER)); //And then the bitmap info header ar.Write(&m_bmpInfoHeader, sizeof(BITMAPINFOHEADER)); ar.Write(m_pDrawingSurfaceBits, lImageSize); ar.Close(); // specify HGLOBAL handle to text data pDataSource->CacheGlobalData(CF_DIB, file.Detach()); pDataSource->SetClipboard(); } CATCH_ALL(e) { delete pDataSource; THROW_LAST(); } END_CATCH_ALL
-
at first, please visit this topic. http://www.codeproject.com/bitmap/drawing2bitmap.asp and my question is below. how to copy the bitmap data to clipboard? Thank you in advance.
-
thank you very much, this one is work. http://www.codeproject.com/clipboard/clipnutshell.asp
-
thank you very much, this one is work. http://www.codeproject.com/clipboard/clipnutshell.asp
you're welcome I gald you find your answer;)
WhiteSky