mfc 在对话框动态加载位图的时候出现Debug Assertion Failed!这是什么情况
代码在下面,编译没有错误,运行出现下面错误,怎么回事/*动态加载图片*/voidCImageProDlg::OnOpen(){//TODO:Addyourcommandh...
代码在下面,编译没有错误,运行出现下面错误,怎么回事
/*动态加载图片*/void CImageProDlg::OnOpen() { // TODO: Add your command handler code here static char BASED_CODE szFilter[]="图片文件(*.bmp)|*.bmp||"; CFileDialog dlg(TRUE,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,szFilter); if(IDOK!=dlg.DoModal()) return; m_Bitmap=(HBITMAP)::LoadImage(AfxGetInstanceHandle(),dlg.GetPathName(), IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION); CBitmap bmp; bmp.Attach(m_Bitmap); CDC* dc = m_HBitmap.GetDC(); CRect m_rect; m_HBitmap.GetClientRect(&m_rect); CDC memDC; memDC.CreateCompatibleDC(dc); memDC.SelectObject(&bmp); BITMAP BitInfo; bmp.GetBitmap(&BitInfo); int x=BitInfo.bmWidth; int y=BitInfo.bmHeight; dc->StretchBlt(m_rect.left,m_rect.top,m_rect.Width(),m_rect.Height(),&memDC,0,0,x,y,SRCCOPY); memDC.DeleteDC();
} 展开
/*动态加载图片*/void CImageProDlg::OnOpen() { // TODO: Add your command handler code here static char BASED_CODE szFilter[]="图片文件(*.bmp)|*.bmp||"; CFileDialog dlg(TRUE,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,szFilter); if(IDOK!=dlg.DoModal()) return; m_Bitmap=(HBITMAP)::LoadImage(AfxGetInstanceHandle(),dlg.GetPathName(), IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION); CBitmap bmp; bmp.Attach(m_Bitmap); CDC* dc = m_HBitmap.GetDC(); CRect m_rect; m_HBitmap.GetClientRect(&m_rect); CDC memDC; memDC.CreateCompatibleDC(dc); memDC.SelectObject(&bmp); BITMAP BitInfo; bmp.GetBitmap(&BitInfo); int x=BitInfo.bmWidth; int y=BitInfo.bmHeight; dc->StretchBlt(m_rect.left,m_rect.top,m_rect.Width(),m_rect.Height(),&memDC,0,0,x,y,SRCCOPY); memDC.DeleteDC();
} 展开
若以下回答无法解决问题,邀请你更新回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询