/* * 添加一张图片 */ bool CYuanListShowImg::AddImg(char *pImgPath) { { // GetScaleBitmap(pImgPath, m_nImgWidth, m_nImgHeight); } int bef = m_imList.GetImageCount(); CPicture pic; int nRet = 0; CBitmap * pBmp = NULL; /*pBmp = new CBitmap(); HBITMAP bmp = NULL; bmp = pic.LoadPicture(pImgPath); nRet = pBmp->Attach(bmp);*/ //必须放外面。不然指针会被销毁导致不显示图案 HBITMAP bmp = NULL; bmp = pic.LoadPicture(pImgPath); pBmp = GetScaleBitmap(bmp, m_nImgWidth, m_nImgHeight); if(NULL == pBmp) { // 插入失败时,必须插入一张默认的图片,不然后面的图片序号会往上移动 // 导致图片显示错乱 nRet = m_imList.Add(m_pDefaultBmp,RGB(0,0,0)); return true; } nRet = m_imList.Add(pBmp,RGB(0,0,0)); if (nRet == -1) { // 插入失败时,必须插入一张默认的图片,不然后面的图片序号会往上移动 // 导致图片显示错乱 nRet = m_imList.Add(m_pDefaultBmp,RGB(0,0,0)); } else { int aft = m_imList.GetImageCount(); if(bef==aft) { nRet = m_imList.Add(m_pDefaultBmp,RGB(0,0,0)); } } delete pBmp; if (nRet == -1) return false; return true; }