List Control for Support ProgressCtrl

源代码及可执行文件下载地址:http://files.cnblogs.com/rainboy2010/ProgressList.zip

List Control for Support ProgressCtrl 

CProgressListCtrl是CListCtrl的扩展类,支持在ListCtrl中显示ProgressCtrl控件。

主要代码如下:

void CProgressListCtrl::OnPaint()

{

	if(m_ProgressColumn>=0)

	{

		int Top=GetTopIndex();

		int Total=GetItemCount();

		int PerPage=GetCountPerPage();

		int LastItem=((Top+PerPage)>Total)?Total:Top+PerPage;



		int Count=(int)m_ProgressList.GetCount();

		for(int i=0;i<Count;i++)

		{

			CProgressCtrl* pControl=m_ProgressList.GetAt(0);

			pControl->DestroyWindow();

			m_ProgressList.RemoveAt(0);

		}



		CRect rcHeader,rcItem;

		CHeaderCtrl* pHeader=GetHeaderCtrl();

		pHeader->GetItemRect(m_ProgressColumn,&rcHeader);



		for(int i=Top;i<LastItem;i++)

		{



			GetItemRect(i,&rcItem,LVIR_LABEL);

			rcItem.top+=1;

			rcItem.bottom-=1;

			rcItem.left+=rcHeader.left;

			int Width=rcHeader.Width();

			rcItem.right=rcItem.left+Width-4;





			CProgressCtrl* pControl=new CProgressCtrl();

			pControl->Create(NULL,rcItem,this,IDC_PROGRESS_LIST+i);



			CString Data=GetItemText(i,0);

			int Percent;

#ifdef _UNICODE

			Percent=_wtoi(Data);

#else

			Percent=atoi(Data);

#endif



			pControl->SetPos(Percent);

			pControl->ShowWindow(SW_SHOWNORMAL);

			m_ProgressList.Add(pControl);

		}





	}



	

	CListCtrl::OnPaint();



	

}

 

  

 

你可能感兴趣的:(progress)