Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Progress Bar is not Progressing!

Status
Not open for further replies.

jsugrue

Programmer
Jun 14, 2002
3
IE
I have written a splash screen which has a bitmap on the top window, and the bottom window consists of the progress bar (a HProgressBar).

It is displayed and everything, but it only shows the progress bar being empty and then full, even though it is only getting through the process slowly. It should be incrementing at certain intervals.

Do I need to send some message saying to display changes in the progress bar.

Here's the creation code :

_hwndPB = CreateWindowEx(0, PROGRESS_CLASS, (LPSTR)NULL, WS_CHILD | WS_VISIBLE | WM_ERASEBKGND, rect.left, rect.bottom-cyVScroll-2, rect.right, cyVScroll, _main, NULL, GetModuleHandle(NULL), NULL);
/**
* Set the range and increment of the progress bar
**/
SendMessage(_hwndPB, PBM_SETRANGE, 0, MAKELPARAM(0, 100));
SendMessage(_hwndPB, PBM_SETSTEP, (WPARAM)1, 0);



And to increment I use :


SendMessage(_hwndPB, PBM_STEPIT, (WPARAM)10, 0);


Please help!

James
 
Rather than using SendMessage() to increment the progressbar (which adds these messages in the message queue until the current function completes), why not make a direct call to the progressbar's incrementing member function from within your loop?
 
instead of using "SendMessage(_hwndPB, PBM_STEPIT, (WPARAM)10, 0);"

try to use "SendMessage(_hwndPB,PBM_SETPOS,(WPARAM)var,0)"

var should be an int variable that indicates the progress of some operation.

if the value of var remain constant, you want see any change on the progress bar;
 
hmmmm, I can't make a call to the ProgressBar as an object, as I am using a HANDLE to HProgressBar.

It tried the SET_POS and SET_DELTAPOS messages, but they didn't work out for me either.


thanks for your suggestions though.. Any more ideas would be greatly appreciated.
 
Try to add those lines in your code.
#define BUTTON 800
....
.......
case WM_COMMAND:
switch(LOWORD(wParam))
{
case BUTTON:
{
for(int stl=0;stl<=100;stl=stl+1)
{
Sleep(8);
SendMessage(_hwndPB,PBM_SETPOS,(WPARAM)stl,0);
}
}
break;
}
break;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top