• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 777
  • Last Modified:

Progress Bar

I need to add a Progress Bar in a List Control Box.
i.e In Report View as an element in a specific column
Can anyone suggest me the procedure to do the same
1 Solution
Roshan DavisCommented:
VS_LearnerAuthor Commented:
I have a Class inheriting CPropertyPage ...
and I have designed a list control in that dialog
I have a problem in integrating the code given in above examples with my LIST CONTROL DIALOG ..
i.e how and where to define those classes and variables
You may create the progress control dynamically (when needed), user it and then destroy it when you are done with it.

The code below is just a simple way to just that:

NOTE: You may need to copy the code below and paste it into notepad (or the VC editor) to be able to see long lines!

1. Add a method called "CProgressCtrl *CreateProgressCtrlInListCtrlItem(CListCtrl &ctrlList, int nItem, int nSubItem)" to you CPropertyPage derived class. The code for this method is shown below:

CProgressCtrl *CDerivedPropPage::CreateProgressCtrlInListCtrlItem(CListCtrl &ctrlList, int nItem, int nSubItem)
            return NULL;

      //Get rectangle for the specified sub-item
      CRect rectSubItem;
      ctrlList.GetSubItemRect(nItem, nSubItem, LVIR_BOUNDS, rectSubItem);

      //Special case handling if nSubItem is 0
      //(GetSubItemRect() returns the whole list width if nSubItem equals 0)
      if(nSubItem == 0)
            rectSubItem.right = rectSubItem.left + ctrlList.GetColumnWidth(nSubItem);

      CProgressCtrl *pCtrl = new CProgressCtrl;
            BOOL bCreated = pCtrl->Create(WS_CHILD | WS_VISIBLE | PBS_SMOOTH,


      return pCtrl;

2. To use this method, you can do something like this:
      CProgressCtrl *pCtrl = CreateProgressCtrlInListCtrlItem(m_list, 0, 0);

      if(pCtrl->GetSafeHwnd()) //Make sure creation of progress succeed
            int nMin = 0;
            int nMax = 100;
            int nStep = 5;

            pCtrl->SetRange32(nMin, nMax);
            while(nMax > pCtrl->GetPos())
                  Sleep(100); //Delay 100 milli seconds

            delete pCtrl;
            pCtrl = NULL;

Khalid Omar.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now