?
Solved

Progress Bar

Posted on 2003-12-03
4
Medium Priority
?
750 Views
Last Modified: 2013-11-20
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
0
Comment
Question by:VS_Learner
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 48

Expert Comment

by:AlexFM
ID: 9865487
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 9865504
0
 

Author Comment

by:VS_Learner
ID: 9866508
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
0
 
LVL 3

Accepted Solution

by:
komar earned 80 total points
ID: 9866992
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)
{
      ASSERT(IsWindow(ctrlList.GetSafeHwnd()));
      if(!IsWindow(ctrlList.GetSafeHwnd()))
            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;
      if(pCtrl)
      {
            BOOL bCreated = pCtrl->Create(WS_CHILD | WS_VISIBLE | PBS_SMOOTH,
                                                 rectSubItem,
                                       &ctrlList,
                                       (UINT)-1);

            if(bCreated)
            {
                  pCtrl->ShowWindow(SW_SHOW);
                  pCtrl->UpdateWindow();
            }
      }

      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);
            pCtrl->SetPos(nMin);
            pCtrl->SetStep(nStep);
            
            while(nMax > pCtrl->GetPos())
            {
                  pCtrl->StepIt();
                  Sleep(100); //Delay 100 milli seconds
            }

            pCtrl->DestroyWindow();
            delete pCtrl;
            pCtrl = NULL;
      }
      ...
      ...

Thanks,
Khalid Omar.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month15 days, 14 hours left to enroll

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question