Index: src/ch/MiniViewDlg.cpp =================================================================== diff -u -r9c71c0a84781c524c0091ee86914d5cc3bbf5190 -ra07af504f54ceb5551be875f0f42e3134d57fabc --- src/ch/MiniViewDlg.cpp (.../MiniViewDlg.cpp) (revision 9c71c0a84781c524c0091ee86914d5cc3bbf5190) +++ src/ch/MiniViewDlg.cpp (.../MiniViewDlg.cpp) (revision a07af504f54ceb5551be875f0f42e3134d57fabc) @@ -131,7 +131,7 @@ RefreshStatus(); - SetTimer(9843, GetConfig().get_signed_num(PP_MVREFRESHINTERVAL), NULL); + SetTimer(9843, (UINT)GetConfig().get_signed_num(PP_MVREFRESHINTERVAL), NULL); } CLanguageDialog::OnTimer(nIDEvent); @@ -268,7 +268,7 @@ RefreshStatus(); // set refresh timer - SetTimer(9843, GetConfig().get_signed_num(PP_MVREFRESHINTERVAL), NULL); + SetTimer(9843, (UINT)GetConfig().get_signed_num(PP_MVREFRESHINTERVAL), NULL); return static_cast(0); } @@ -401,16 +401,19 @@ break; } case MSG_ONCLICK: - int iSel=pDlg->m_ctlStatus.GetCurSel(); - if (iSel == LB_ERR) - return; - CTask* pTask; - if ( (pTask=pDlg->m_ctlStatus.m_items.GetAt(iSel)->m_pTask) != NULL) - pTask->PauseProcessing(); - else - pDlg->m_pTasks->TasksPauseProcessing(); + { + int iSel=pDlg->m_ctlStatus.GetCurSel(); + if (iSel == LB_ERR || (size_t)iSel >= pDlg->m_ctlStatus.m_vItems.size()) + return; - break; + CTask* pTask; + if ( (pTask=pDlg->m_ctlStatus.m_vItems.at(iSel)->m_pTask) != NULL) + pTask->PauseProcessing(); + else + pDlg->m_pTasks->TasksPauseProcessing(); + + break; + } } } @@ -506,20 +509,22 @@ break; } case MSG_ONCLICK: - int iSel=pDlg->m_ctlStatus.GetCurSel(); - if (iSel == LB_ERR) - return; - CTask* pTask; - if ( (pTask=pDlg->m_ctlStatus.m_items.GetAt(iSel)->m_pTask) != NULL) { - if (pTask->GetStatus(ST_WAITING_MASK) & ST_WAITING) - pTask->SetForceFlag(true); + int iSel=pDlg->m_ctlStatus.GetCurSel(); + if (iSel == LB_ERR || (size_t)iSel >= pDlg->m_ctlStatus.m_vItems.size()) + return; + CTask* pTask; + if ( (pTask=pDlg->m_ctlStatus.m_vItems.at(iSel)->m_pTask) != NULL) + { + if (pTask->GetStatus(ST_WAITING_MASK) & ST_WAITING) + pTask->SetForceFlag(true); + else + pTask->ResumeProcessing(); + } else - pTask->ResumeProcessing(); + pDlg->m_pTasks->TasksResumeProcessing(); + break; } - else - pDlg->m_pTasks->TasksResumeProcessing(); - break; } } @@ -550,10 +555,10 @@ } case MSG_ONCLICK: int iSel=pDlg->m_ctlStatus.GetCurSel(); - if (iSel == LB_ERR) + if (iSel == LB_ERR || (size_t)iSel >= pDlg->m_ctlStatus.m_vItems.size()) return; CTask* pTask; - if ( (pTask=pDlg->m_ctlStatus.m_items.GetAt(iSel)->m_pTask) != NULL) + if ( (pTask=pDlg->m_ctlStatus.m_vItems.at(iSel)->m_pTask) != NULL) pTask->CancelProcessing(); else pDlg->m_pTasks->TasksCancelProcessing(); @@ -602,15 +607,17 @@ break; } case MSG_ONCLICK: - int iSel=pDlg->m_ctlStatus.GetCurSel(); - if (iSel == LB_ERR) - return; - CTask* pTask; - if ( (pTask=pDlg->m_ctlStatus.m_items.GetAt(iSel)->m_pTask) != NULL) - pTask->RestartProcessing(); - else - pDlg->m_pTasks->TasksRestartProcessing(); - break; + { + int iSel=pDlg->m_ctlStatus.GetCurSel(); + if (iSel == LB_ERR || (size_t)iSel >= pDlg->m_ctlStatus.m_vItems.size()) + return; + CTask* pTask; + if ( (pTask=pDlg->m_ctlStatus.m_vItems.at(iSel)->m_pTask) != NULL) + pTask->RestartProcessing(); + else + pDlg->m_pTasks->TasksRestartProcessing(); + break; + } } } @@ -795,10 +802,10 @@ void CMiniViewDlg::OnDblclkProgressList() { int iSel=m_ctlStatus.GetCurSel(); - if (iSel == LB_ERR) + if (iSel == LB_ERR || (size_t)iSel >= m_ctlStatus.m_vItems.size()) return; CTask* pTask; - pTask=m_ctlStatus.m_items.GetAt(iSel)->m_pTask; + pTask=m_ctlStatus.m_vItems.at(iSel)->m_pTask; GetParent()->PostMessage(WM_MINIVIEWDBLCLK, 0, (LPARAM)pTask); } Index: src/ch/ProgressListBox.cpp =================================================================== diff -u -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) Index: src/ch/ProgressListBox.h =================================================================== diff -u -r9c71c0a84781c524c0091ee86914d5cc3bbf5190 -ra07af504f54ceb5551be875f0f42e3134d57fabc --- src/ch/ProgressListBox.h (.../ProgressListBox.h) (revision 9c71c0a84781c524c0091ee86914d5cc3bbf5190) +++ src/ch/ProgressListBox.h (.../ProgressListBox.h) (revision a07af504f54ceb5551be875f0f42e3134d57fabc) @@ -28,7 +28,7 @@ struct _PROGRESSITEM_ { CString m_strText; - + UINT m_uiPos; UINT m_uiRange; @@ -48,7 +48,7 @@ // Operations public: - CArray<_PROGRESSITEM_*, _PROGRESSITEM_*> m_items; + std::vector<_PROGRESSITEM_*> m_vItems; protected: bool m_bShowCaptions; @@ -57,7 +57,7 @@ // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CProgressListBox) - public: +public: virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct); //}}AFX_VIRTUAL