I thought I would try my code in debug mode:
void CSpecialEventVideoconferenceInfoDlg::OnEnChangeBrowseSpecialEventVideoconfPathImage()
{
CString strImagePath;
GetDlgItemText(IDC_BROWSE_SPECIAL_EVENT_VIDEOCONF_PATH_IMAGE, strImagePath);
m_imgPreview.Load(strImagePath);
}
It is very simple and triggers m_imgPreview
to load a new image. This variable is of type CImage
. I notice in debug mode that when I select a second image that I get an exception raised:
inline void CImage::Attach(
_In_ HBITMAP hBitmap,
_In_ DIBOrientation eOrientation) throw()
{
ATLASSUME( m_hBitmap == NULL );
ATLASSERT( hBitmap != NULL );
m_hBitmap = hBitmap;
UpdateBitmapInfo(eOrientation);
}
It fails on this line:
ATLASSUME( m_hBitmap == NULL );
I have looked at the documentation for this (CImage::Load
) and it says nothing about this scenario. What is the correct way to cater for loading another image when there is already an image loaded into the CImage
object?