Solved

Progress Bar

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

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

777 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