Progress bar not showing visual progress
Author |
Message |
Jim #1 / 8
|
 Progress bar not showing visual progress
Hi All, I'm using evc 4.0. i have created a dialog and inside that i have put one progress bar control t design time. I have initialsed like this: INITCOMMONCONTROLSEX initCtrls; initCtrls.dwSize = sizeof(INITCOMMONCONTROLSEX); initCtrls.dwICC = ICC_PROGRESS_CLASS ; if (!InitCommonControlsEx(&initCtrls)) { MessageBox (NULL,_T("error in creation"), _T("Alert!!"), MB_OK); return false; Quote: }
Get the handle to the control TempHandle = GetDlgItem(hDlg,IDC_PROGRESS1); SendMessage(TempHandle,PBM_SETRANGE,0,100); SendMessage(TempHandle,PBM_SETSTEP,1,0); Now i have tried using STEPIT like this /////////////////////////// for( int i = 1; i<=100;i++) { SendMessage(TempHandle,PBM_STEPIT,0,0); Quote: }
but it didn't show any progress then i used /////////////////////////// for( int i = 1; i<=100;i++) { SendMessage(TempHandle,PBM_STEPIT,0,0); SendMessage(TempHandle,PBM_SETPOS,i,NULL); Quote: }
Now what happens is that the progress bar at one strach get filled and do not show any visual representation of progressing. The progress bar is full everytime i see to it. I want to see it expanding one by one. can anyone tell me whats wrong here. thankx in advance -Jim
|
Tue, 10 May 2005 17:05:50 GMT |
|
 |
enzoti #2 / 8
|
 Progress bar not showing visual progress
| | I'm using evc 4.0. i have created a dialog and inside that | i have put one progress bar control t design time. I have | initialsed like this: | | ....... | | then i used | /////////////////////////// | for( int i = 1; i<=100;i++) | { | SendMessage(TempHandle,PBM_STEPIT,0,0); | SendMessage(TempHandle,PBM_SETPOS,i,NULL); | } | | Now what happens is that the progress bar at one strach | get filled and do not show any visual representation of | progressing. The progress bar is full everytime i see to | it. I want to see it expanding one by one. can anyone tell | me whats wrong here. | You don't wont to send the messages in a tight loop. You have to increment the progress bar putting some time interval between each two steps, depending on some other info. As an example, if you know the totale time required, say this is T secs, do an increment each n = T/100 secs with a timer, for a total of 100 increment. As another example, if your long process require n sub-process do an increment each n/100 sub-processes, for a total of 100 increment. -- Vincenzo.
|
Wed, 11 May 2005 04:44:53 GMT |
|
 |
Jim #3 / 8
|
 Progress bar not showing visual progress
Hi Vincenzo, Thankx for the feedback. I have already tried the same by putting delay (Sleep()) in the loop. but strangely for the whole loop the sleep works all together at one time and then progress bar came again with same speed and i can't see that progress. I tried by giving messagebox but similar to sleep all messages start poping n numbers of time and then at the last the progress bar is drwan fully at one go. any idea? -Jim ////////////// for( int i = 1; i<=100;i++) { Sleep(100); MessageBox(NULL,TEXT("here"),_T("Alert!"),MB_OK); SendMessage(TempHandle,PBM_STEPIT,0,0); SendMessage(TempHandle,PBM_SETPOS,i,NULL); Quote: }
/////////////////////// Quote: >-----Original Message-----
>| >| I'm using evc 4.0. i have created a dialog and inside that >| i have put one progress bar control t design time. I have >| initialsed like this: >| >| ....... >| >| then i used >| /////////////////////////// >| for( int i = 1; i<=100;i++) >| { >| SendMessage(TempHandle,PBM_STEPIT,0,0); >| SendMessage(TempHandle,PBM_SETPOS,i,NULL); >| } >| >| Now what happens is that the progress bar at one strach >| get filled and do not show any visual representation of >| progressing. The progress bar is full everytime i see to >| it. I want to see it expanding one by one. can anyone tell >| me whats wrong here. >| >You don't wont to send the messages in a tight loop. >You have to increment the progress bar putting some time interval >between each two steps, depending on some other info. >As an example, if you know the totale time required, say this is T secs, >do an increment each n = T/100 secs with a timer, for a total of 100 >increment. >As another example, if your long process require n sub- process >do an increment each n/100 sub-processes, for a total of 100 increment. >-- >Vincenzo. >.
|
Wed, 11 May 2005 13:24:55 GMT |
|
 |
enzoti #4 / 8
|
 Progress bar not showing visual progress
| Hi Vincenzo, | Thankx for the feedback. I have already tried the same by | putting delay (Sleep()) in the loop. but strangely for the | whole loop the sleep works all together at one time and | then progress bar came again with same speed and i can't | see that progress. I tried by giving messagebox but | similar to sleep all messages start poping n numbers of | time and then at the last the progress bar is drwan fully | at one go. | | any idea? | I know if you are inside a window message handler, the window cannot handle WM_PAINT message, so no refresh can be viewed. This might hold also for child controls. So try to SetTimer(hWnd, 1, 500, 0); Then in the WM_TIMER message handler do your SendMessage(TempHandle,PBM_STEPIT,0,0); SendMessage(TempHandle,PBM_SETPOS,i,NULL); Note that you may have the need to declare i as global or static. -- Vincenzo.
|
Thu, 12 May 2005 05:17:21 GMT |
|
 |
Jimm #5 / 8
|
 Progress bar not showing visual progress
I have tried with timer also but it didn't worked moreover the progress is not showing any progress now. My code is like this. I have a dialog and a progress bar control has been drwan on that.IDC_BUTTON1 is the button when pressed i want the bar to be drawn ============================================== case WM_COMMAND: if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam)==IDCANCEL)) { EndDialog(hDlg, LOWORD(wParam)); return TRUE; Quote: }
else if((LOWORD(wParam) == IDC_BUTTON1)) { TempHandle = GetDlgItem(hDlg,IDC_PROGRESS1); SendMessage(TempHandle,PBM_SETRANGE,0,10); SendMessage(TempHandle,PBM_SETSTEP,1,0); SetTimer(hDlg, 10025, 2000, 0); /*for(i = 1; i<=100;i++) { SendMessage(TempHandle,PBM_STEPIT,0,0); SendMessage(TempHandle,PBM_SETPOS,i,NULL); Quote: }*/ }
break; case WM_TIMER: MessageBox(NULL,_T("Alert!"),_T("szFinalAddr"),MB_OK); SendMessage(TempHandle,PBM_STEPIT,1,0); SendMessage(TempHandle,PBM_SETPOS,i,NULL); break; Can u see something missing here? -Thnakx Quote: >-----Original Message-----
>| Hi Vincenzo, >| Thankx for the feedback. I have already tried the same by >| putting delay (Sleep()) in the loop. but strangely for the >| whole loop the sleep works all together at one time and >| then progress bar came again with same speed and i can't >| see that progress. I tried by giving messagebox but >| similar to sleep all messages start poping n numbers of >| time and then at the last the progress bar is drwan fully >| at one go. >| >| any idea? >| >I know if you are inside a window message handler, the window cannot >handle WM_PAINT message, so no refresh can be viewed. >This might hold also for child controls. >So try to > SetTimer(hWnd, 1, 500, 0); >Then in the WM_TIMER message handler do your > SendMessage(TempHandle,PBM_STEPIT,0,0); > SendMessage(TempHandle,PBM_SETPOS,i,NULL); >Note that you may have the need to declare i as global or static. >-- >Vincenzo. >.
|
Fri, 13 May 2005 16:10:22 GMT |
|
 |
enzoti #6 / 8
|
 Progress bar not showing visual progress
| I have tried with timer also but it didn't worked moreover | the progress is not showing any progress now. | | My code is like this. I have a dialog and a progress bar | control has been drwan on that.IDC_BUTTON1 is the button | when pressed i want the bar to be drawn | ============================================== | case WM_COMMAND: | if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam)==IDCANCEL)) | { | EndDialog(hDlg, LOWORD(wParam)); | return TRUE; | } | else if((LOWORD(wParam) == IDC_BUTTON1)) | { | TempHandle = GetDlgItem(hDlg,IDC_PROGRESS1); | SendMessage(TempHandle,PBM_SETRANGE,0,10); | SendMessage(TempHandle,PBM_SETSTEP,1,0); | SetTimer(hDlg, 10025, 2000, 0); | /*for(i = 1; i<=100;i++) | { | SendMessage(TempHandle,PBM_STEPIT,0,0); | SendMessage(TempHandle,PBM_SETPOS,i,NULL); | }*/ | } | break; | case WM_TIMER: | MessageBox(NULL,_T("Alert!"),_T("szFinalAddr"),MB_OK); | SendMessage(TempHandle,PBM_STEPIT,1,0); | SendMessage(TempHandle,PBM_SETPOS,i,NULL); | break; | | Can u see something missing here? | | -Thnakx | where and how 'i' is defined/declared? you can see the MsgBoxes? -- Vincenzo.
|
Fri, 13 May 2005 17:19:26 GMT |
|
 |
jim #7 / 8
|
 Progress bar not showing visual progress
It didn't worked . I have created a dialog and drawn progress bar control over it at design time. in DLGPROC for that dialog code is: ========================================== WM_Command : if((LOWORD(wParam) == IDC_BUTTON1)) { TempHandle = GetDlgItem(hDlg,IDC_PROGRESS1); SendMessage(TempHandle,PBM_SETRANGE,0,10); SendMessage(TempHandle,PBM_SETSTEP,1,0); SetTimer(hDlg, 10025, 2000, 0); Quote: }
break; case WM_TIMER: MessageBox(NULL,_T("inside timer"),_T ("szFinalAddr"),MB_OK); i = i+10; SendMessage(TempHandle,PBM_STEPIT,1,0); SendMessage(TempHandle,PBM_SETPOS,i,NULL); Quote: >-----Original Message-----
>| Hi Vincenzo, >| Thankx for the feedback. I have already tried the same by >| putting delay (Sleep()) in the loop. but strangely for the >| whole loop the sleep works all together at one time and >| then progress bar came again with same speed and i can't >| see that progress. I tried by giving messagebox but >| similar to sleep all messages start poping n numbers of >| time and then at the last the progress bar is drwan fully >| at one go. >| >| any idea? >| >I know if you are inside a window message handler, the window cannot >handle WM_PAINT message, so no refresh can be viewed. >This might hold also for child controls. >So try to > SetTimer(hWnd, 1, 500, 0); >Then in the WM_TIMER message handler do your > SendMessage(TempHandle,PBM_STEPIT,0,0); > SendMessage(TempHandle,PBM_SETPOS,i,NULL); >Note that you may have the need to declare i as global or static. >-- >Vincenzo. >.
|
Fri, 13 May 2005 20:19:13 GMT |
|
 |
Jimm #8 / 8
|
 Progress bar not showing visual progress
hi Vincenzo, i is global and yes msgboxes are coming. -Jim Quote: >-----Original Message-----
>| I have tried with timer also but it didn't worked moreover >| the progress is not showing any progress now. >| >| My code is like this. I have a dialog and a progress bar >| control has been drwan on that.IDC_BUTTON1 is the button >| when pressed i want the bar to be drawn >| ============================================== >| case WM_COMMAND: >| if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) ==IDCANCEL)) >| { >| EndDialog(hDlg, LOWORD(wParam)); >| return TRUE; >| } >| else if((LOWORD(wParam) == IDC_BUTTON1)) >| { >| TempHandle = GetDlgItem(hDlg,IDC_PROGRESS1); >| SendMessage(TempHandle,PBM_SETRANGE,0,10); >| SendMessage(TempHandle,PBM_SETSTEP,1,0); >| SetTimer(hDlg, 10025, 2000, 0); >| /*for(i = 1; i<=100;i++) >| { >| SendMessage(TempHandle,PBM_STEPIT,0,0); >| SendMessage(TempHandle,PBM_SETPOS,i,NULL); >| }*/ >| } >| break; >| case WM_TIMER: >| MessageBox(NULL,_T("Alert!"),_T("szFinalAddr"),MB_OK); >| SendMessage(TempHandle,PBM_STEPIT,1,0); >| SendMessage(TempHandle,PBM_SETPOS,i,NULL); >| break; >| >| Can u see something missing here? >| >| -Thnakx >| >where and how 'i' is defined/declared? >you can see the MsgBoxes? >-- >Vincenzo. >.
|
Fri, 13 May 2005 20:57:56 GMT |
|
|
|