Index: src/ch/ProgressListBox.cpp =================================================================== diff -u -N -r9c71c0a84781c524c0091ee86914d5cc3bbf5190 -ra07af504f54ceb5551be875f0f42e3134d57fabc --- src/ch/ProgressListBox.cpp (.../ProgressListBox.cpp) (revision 9c71c0a84781c524c0091ee86914d5cc3bbf5190) +++ src/ch/ProgressListBox.cpp (.../ProgressListBox.cpp) (revision a07af504f54ceb5551be875f0f42e3134d57fabc) @@ -39,10 +39,10 @@ CProgressListBox::~CProgressListBox() { - for (int i=0;i::iterator iter = m_vItems.begin(); iter != m_vItems.end(); ++iter) + { + delete *iter; + } } @@ -59,9 +59,9 @@ void CProgressListBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { - if (lpDrawItemStruct->itemID == -1) + if (lpDrawItemStruct->itemID == -1 || lpDrawItemStruct->itemID >= m_vItems.size()) return; - _PROGRESSITEM_* pItem=m_items.GetAt(lpDrawItemStruct->itemID); + _PROGRESSITEM_* pItem=m_vItems.at(lpDrawItemStruct->itemID); // device context CDC* pDC=CDC::FromHandle(lpDrawItemStruct->hDC); @@ -72,8 +72,8 @@ // fill with color, because in other way the trash appears pDC->FillSolidRect(&lpDrawItemStruct->rcItem, GetSysColor(COLOR_3DFACE)); CPoint apt[3]={ CPoint(lpDrawItemStruct->rcItem.left, lpDrawItemStruct->rcItem.top+(lpDrawItemStruct->rcItem.bottom-lpDrawItemStruct->rcItem.top)/4), - CPoint(lpDrawItemStruct->rcItem.left, lpDrawItemStruct->rcItem.top+3*((lpDrawItemStruct->rcItem.bottom-lpDrawItemStruct->rcItem.top)/4)), - CPoint(lpDrawItemStruct->rcItem.left+7, lpDrawItemStruct->rcItem.top+(lpDrawItemStruct->rcItem.bottom-lpDrawItemStruct->rcItem.top)/2) }; + CPoint(lpDrawItemStruct->rcItem.left, lpDrawItemStruct->rcItem.top+3*((lpDrawItemStruct->rcItem.bottom-lpDrawItemStruct->rcItem.top)/4)), + CPoint(lpDrawItemStruct->rcItem.left+7, lpDrawItemStruct->rcItem.top+(lpDrawItemStruct->rcItem.bottom-lpDrawItemStruct->rcItem.top)/2) }; pDC->Polygon(apt, 3); lpDrawItemStruct->rcItem.left+=10; } @@ -95,9 +95,9 @@ // progress like drawing int iBoxWidth=static_cast(static_cast(((9+2)-2*iEdgeWidth))*(2.0/3.0))+1; CRect rcProgress(lpDrawItemStruct->rcItem.left, lpDrawItemStruct->rcItem.bottom-(9+2), - lpDrawItemStruct->rcItem.left+2*iEdgeWidth+((lpDrawItemStruct->rcItem.right-lpDrawItemStruct->rcItem.left-2*iEdgeWidth)/iBoxWidth)*iBoxWidth, - lpDrawItemStruct->rcItem.bottom); - + lpDrawItemStruct->rcItem.left+2*iEdgeWidth+((lpDrawItemStruct->rcItem.right-lpDrawItemStruct->rcItem.left-2*iEdgeWidth)/iBoxWidth)*iBoxWidth, + lpDrawItemStruct->rcItem.bottom); + // edge pDC->Draw3dRect(&rcProgress, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHIGHLIGHT)); @@ -107,7 +107,7 @@ double dCount=static_cast(static_cast(((rcProgress.Width()-2*iEdgeHeight)/iBoxWidth)) *(static_cast(pItem->m_uiPos)/static_cast(pItem->m_uiRange))); int iBoxCount=((dCount-static_cast(dCount)) > 0.2) ? static_cast(dCount)+1 : static_cast(dCount); - + for (int i=0;iFillSolidRect(lpDrawItemStruct->rcItem.left+i*iBoxWidth+iEdgeWidth+1, lpDrawItemStruct->rcItem.bottom-(9+2)+iEdgeHeight+1, @@ -151,7 +151,7 @@ void CProgressListBox::RecalcHeight() { // new height - int iCtlHeight=m_items.GetSize()*GetItemHeight(0); + int iCtlHeight=m_vItems.size()*GetItemHeight(0); // change control size CRect rcCtl; @@ -171,34 +171,37 @@ _PROGRESSITEM_* CProgressListBox::GetItemAddress(int iIndex) { - if (m_items.GetSize() > iIndex) - return m_items.GetAt(iIndex); + if (m_vItems.size() > iIndex) + return m_vItems.at(iIndex); else { _PROGRESSITEM_* pItem=new _PROGRESSITEM_; pItem->m_uiRange=100; - m_items.Add(pItem); + m_vItems.push_back(pItem); return pItem; } } void CProgressListBox::UpdateItems(int nLimit, bool bUpdateSize) { // delete items from array - while (m_items.GetSize() > nLimit) + if(m_vItems.size() > nLimit) { - delete m_items.GetAt(nLimit); - m_items.RemoveAt(nLimit); + std::vector<_PROGRESSITEM_*>::iterator iterStart = m_vItems.begin() + nLimit; + for(std::vector<_PROGRESSITEM_*>::iterator iterPos = iterStart; iterPos != m_vItems.end(); ++iterPos) + { + delete *iterPos; + } + m_vItems.erase(iterStart, m_vItems.end()); } - // change count of elements in a listbox - if (GetCount() != m_items.GetSize()) + if (GetCount() != m_vItems.size()) { - while (GetCount() < m_items.GetSize()) + while (GetCount() < m_vItems.size()) AddString(_T("")); - - while (GetCount() > m_items.GetSize()) - DeleteString(m_items.GetSize()); + + while (GetCount() > m_vItems.size()) + DeleteString(m_vItems.size()); } if (bUpdateSize)