Making Graphical effect from Progress Bar






3.49/5 (28 votes)
Jun 21, 2004

64854

1999
Usage of Progress Bar control.
Introduction
MFC provides the CProgressCtrl
class that helps to make the Windows progress bar control. CProgressCtrl
is derived directly from Cwnd
class and inherits the function of Cwnd
class. It can be created as a child control of any window and also you can use from the dialog resource template.
I need the control that shows graphical effect in changing the sound level, so I made this application which is presented to you. I used it in a voice graph application using different voices. Here I used timer to show the graphical effect of progress bar.
Thing Required
- Microsoft Visual C++ 6.0.
- Microsoft Windows 9x/2000/XP.
Code
void CGraphProgressView::OnButton1() { BOOL fRun = FALSE; if(fRun) { m_btnRun.SetWindowText("Run"); KillTimer(1); } else { m_btnRun.SetWindowText("Stop"); SetTimer(1,85, 0); } fRun = !fRun; } void CGraphProgressView::DoDataExchange(CDataExchange* pDX) { CFormView::DoDataExchange(pDX); //{{AFX_DATA_MAP(CGraphProgressView) DDXControl(pDX, IDC_BUTTON1, btnRun); DDX_Control(pDX, IDC_PROGRESS1, m_progress1); DDX_Control(pDX, IDC_PROGRESS2, m_progress2); DDX_Control(pDX, IDC_PROGRESS3, m_progress3); DDX_Control(pDX, IDC_PROGRESS4, m_progress4); DDX_Control(pDX, IDC_PROGRESS5, m_progress5); DDX_Control(pDX, IDC_PROGRESS6, m_progress6); DDX_Control(pDX, IDC_PROGRESS7, m_progress7); DDX_Control(pDX, IDC_PROGRESS8, m_progress8); DDX_Control(pDX, IDC_PROGRESS9, m_progress9); DDX_Control(pDX, IDC_PROGRESS10, m_progress10); DDX_Control(pDX, IDC_PROGRESS11, m_progress11); DDX_Control(pDX, IDC_PROGRESS12, m_progress12); DDX_Control(pDX, IDC_PROGRESS13, m_progress13); DDX_Control(pDX, IDC_PROGRESS14, m_progress14); DDX_Control(pDX, IDC_PROGRESS15, m_progress15); // NOTE: the ClassWizard will add DDX and DDV calls here //}}AFX_DATA_MAP }
Class Methods
I used the two methods of the CProgressCtrl
class.
SetStep() |
It shows the step increment for a progress bar control. |
SetIt() |
It advances the current position for a progress bar control by the step increment and redraws the bar to show the new position. |
Using the MFC AppWizard (exe) application: choose the base class CFormView
, to make this application. Try to make it and enjoy.