Solved

Progress Bar

Posted on 2003-12-03
4
690 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
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 20 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
List out all word 7 255
WinWaitActive parameters 12 31
only14 challenge 19 68
ShiftLeft challenge 21 76
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

932 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now