jlehenbauer
jlehenbauer

Reputation: 599

Problems creating progress bar in Visual Studio using MFC

i'm trying to simply fill a progress bar, full when a check box is checked, and empty when the box is unchecked. there is an ONCLICK action for the check box, so i figured i would check the value every time it was clicked, and would fill the bar only when it was checked.

this code includes a couple different things i tried, anything with progCtrl gave me a runtime error. any thoughts would be helpful, thanks!

void Cgui1Dlg::OnBnClickedsetkill()
{
    // TODO: Add your control notification handler code here
    //IDC_PROGRESS.Value = 100;
    //CProgressCtrl progCtrl;
    //progCtrl.SetDlgCtrlID(IDC_PROGRESS);
    //UpdateData();
    //if(changefill)
    //{
        //IDC_PROGRESS.PBM_SETPOS(100);
        //SendMessage(IDC_PROGRESS, PBM_SETPOS, 100); 
    //progCtrl.SetPos(100);
    //}
    //else
    //{
        //filled = FALSE;
    //}
    UpdateData(FALSE);
}

Upvotes: 0

Views: 1230

Answers (1)

MikMik
MikMik

Reputation: 3466

I would create a control variable for the progress control and the check button. Then, do:

void Cgui1Dlg::OnBnClickedsetkill()
{
    if(c_Check.GetCheck()==BST_CHECKED)
    {
        c_Progress.SetPos(100);
    }
    else
    {
        c_Progress.SetPos(0);
    }
}

Upvotes: 1

Related Questions