Click here to Skip to main content
15,888,330 members
Articles / Desktop Programming / MFC
Article

Making Graphical effect from Progress Bar

Rate me:
Please Sign up or sign in to vote.
3.44/5 (27 votes)
20 Jun 2004 64.1K   2K   17   4
Usage of Progress Bar control.

Sample screenshot

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.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Pakistan Pakistan
I did Msc Computer Scicences specialization in software engineering from University of Management and Technology Lahore,and having the experience of IT for more than 5 years.
I have worked in different programming languages, such as: C, C++, Visual C++,Java, Visual Basic and C#, also in PHP, HTML, ASP, ASP.NET and also CCNA & RedHat Linux. Love Mathematics. I have always been fascinated by .NET, so now I am programming in .NET.

You can email me: only_boby@hotmail.com
Visit my web site: http://www28.brinkster.com/abdulhye

Comments and Discussions

 
Questioncan i used it for sound level Pin
Williamt22-Jun-04 3:42
Williamt22-Jun-04 3:42 
AnswerRe: can i used it for sound level Pin
Abdul Hye4-Jul-04 1:35
Abdul Hye4-Jul-04 1:35 
Questionhow to use CFormview Pin
coco_5521-Jun-04 22:07
coco_5521-Jun-04 22:07 
AnswerRe: how to use CFormview Pin
Abdul Hye4-Jul-04 1:40
Abdul Hye4-Jul-04 1:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.