Click here to Skip to main content
11,721,385 members (78,331 online)
Click here to Skip to main content

Adding progress bars to a list control

, 2 Sep 2001 134.3K 2.5K 78
Rate this:
Please Sign up or sign in to vote.
A simple extension that allows you to add a progress indicator as an item in a list control
<!-- Download Links --> <!-- Article image -->

Sample Image - napster.jpg

<!-- Main HTML starts here -->

Introduction

This code shows how to add a progress control to a listview control. If you want to use this code, copy listctrlex.h and listctrlex.cpp to your project and subclass it.

These files are good examples of owner-draw control and custom draw list controls. if you want to visually show various data in your listview controls (such as progress, which is done here), you'll need these.

There is another way to show a progress control in a listview control - that is embedding progress bar control in your listview control. For this case that isn't necessary because the code presented here works properly and I don't want to worry about processing child window's messages.

I implemented and tested on Windows 2000 Proffesional, Visual C++ 6.0 with Service Pack 5. Untested under Unicode.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Jinhyuck Jung
Korea (Republic Of) Korea (Republic Of)
No Biography provided

You may also be interested in...

Comments and Discussions

 
GeneralNeedes updating Pin
Donsw11-Dec-08 11:15
memberDonsw11-Dec-08 11:15 
GeneralMy vote of 2 Pin
Donsw11-Dec-08 11:14
memberDonsw11-Dec-08 11:14 
GeneralIt can do more... Pin
Mikeylas30-Oct-06 18:32
memberMikeylas30-Oct-06 18:32 
GeneralIgnore the below comments (+fix) Pin
AnthonyJ28-Apr-03 7:33
memberAnthonyJ28-Apr-03 7:33 
GeneralMore Effecient Method Pin
Zac Howland22-Mar-02 5:45
memberZac Howland22-Mar-02 5:45 
Here is a more effecient method to dynamically embed progress bars into a list ctrl.   (I used a CView-derived class -- though you can do pretty much the same thing in a CListCtrl-derived class).

<code>
void CEmbeddedProgressTest1View::OnPaint()
{
     CListCtrl& wndList = GetListCtrl();
     CHeaderCtrl* pwndHead = wndList.GetHeaderCtrl();

     CClientDC dc(this);

     int iIndex = wndList.GetTopIndex();
     for (int i = 0; i < wndList.GetItemCount() && i < wndList.GetCountPerPage(); i++, iIndex++)
     {
          CRect rcItem;
          wndList.GetSubItemRect(i, m_iProgress, LVIR_BOUNDS, rcItem);
          CProgressCtrl* pProgress = (CProgressCtrl*)m_paProgressBars.GetAt(iIndex);
          pProgress->MoveWindow(rcItem, TRUE);
          pProgress->Invalidate();
     }
     CListView::OnPaint();
}
</code>

For this example, I created my Progress bars in OnInitialUpdate and set their ranges and steps there, though you can do those anywhere.   I also had a member variable (m_paProgressBars) that stored the pointers to the progress bars after creation. (The index of the pointer in the array is also the item number in the list).   Another member variable (m_iProgress), indicated the SubItem number where the progress bars should be drawn.

Zac Howland
GeneralHERE's the correct way Pin
Mike Luongo8-Dec-01 8:31
memberMike Luongo8-Dec-01 8:31 
GeneralRe: HERE's the correct way Pin
Max Santos19-Jul-03 15:51
memberMax Santos19-Jul-03 15:51 
GeneralYOU'RE DOING IT ALL WRONG!!! Pin
Mike Luongo8-Dec-01 8:16
memberMike Luongo8-Dec-01 8:16 
GeneralMany bugs Pin
Tre20-Nov-01 14:29
memberTre20-Nov-01 14:29 
GeneralRe: Many bugs Pin
AnthonyJ28-Apr-03 7:16
memberAnthonyJ28-Apr-03 7:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150901.1 | Last Updated 3 Sep 2001
Article Copyright 2001 by Jinhyuck Jung
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid