Problem usage CImage and Clipboard
When I do this, I got ASSERT inside CImage::ReleaseDC(), What's wrong?
HBITMAP hBitmap = (HBITMAP)GetClipboardData(CF_BITMAP);
CImage m_CImage.Attach( hBitmap );
CWnd::OnPaint()
{
CPaintDc dc(this);
CRect rect;
GetClientRect( &rect );
m_CImage.Draw( dc.m_hDC, rect ); //ASSERT inside!
}
[395 byte] By [
michot] at [2007-12-24]
michot hi,
You should propably provide more code, so we would be more accurate of what is happening. There are many cases of the error's reason:
- first if the program executes two times the 'm_CImage.Attach' without execute the 'm_CImage.Detach', assert occurs. So you must be ensure that 'Attach' 'Detach' exeuted in pairs.
- Then provide check for 'hBitmap' handle. If it is NULL then assert may occur (propably in 'Attach')
Also make use of 'GetLastError' to get error information