Aster Veigas
Aster Veigas

Reputation: 876

Progress bar not updating in Win32

I create a Progress bar in Win32 and it does not update when I'm building the application in Release configuration but works in the Debug configuration. The progress bar is created as follows:

progBar= CreateWindowEx(0,PROGRESS_CLASS,NULL,WS_CHILD | WS_VISIBLE|PBS_SMOOTH,rc.right/2-130,rc.bottom/2, 260, 17,hWnd, NULL, hInst, NULL);

        //Sets the range of progress bar
        SendMessage(progBar, PBM_SETRANGE, 0, MAKELPARAM(0,10));    //0->min value; 10->max value
        SetTimer(hWnd, TIMER_1, 1000, TimerProc);                   //set the timer

and my TimerProc is :

void CALLBACK TimerProc(HWND hWnd, UINT msg, UINT idEvent, DWORD dwTime)
{

switch(msg)
{
    case WM_TIMER:
    {
        SendMessage(progBar, PBM_SETPOS,stepValue,0);       //stepValue
        InvalidateRect(progBar,NULL,TRUE);

        if(stepValue>9)
        {
            stepValue=0;
        }

        else
        {
            stepValue++;
        }
    }
  }
  return;
}

I'm using Visual Studio 2010.Is it possible I'm missing some library since it works in Debug configuration. The runtime library I've selected is Multi-threaded (/MT)

Upvotes: 1

Views: 1956

Answers (1)

Aster Veigas
Aster Veigas

Reputation: 876

According to Hans I tried the Marquee style progress bar and it worked. The code change will be as follows:

        progBar= CreateWindowEx(0,PROGRESS_CLASS,NULL,WS_CHILD | WS_VISIBLE|PBS_MARQUEE,rc.right/2-130,rc.bottom/2, 260, 17,hWnd, NULL, hInst, NULL);

        SendMessage(progBar, PBM_SETMARQUEE,TRUE,50); 

and I removed the SetRange statement.According to this link

http://social.msdn.microsoft.com/Forums/vstudio/en-US/407cf8d0-02cc-4276-adb1-3fc619ce4f3a/progress-bar-with-marquee-style

I had to add

#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") 

else the Marquee progress bar would not work. Could some one explain this? But this works for me on Release builds as well.

Upvotes: 1

Related Questions