Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Timer Dialog with progress bar
#1
The timer in the following dialog function is programmed to run for 30s. Nevertheless, it actually runs for 32.703s! I would appreciate any advise regarding my error. Many thanks in advance.

Function Timer_progress_TT
Code:
Copy      Help
;\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

;EXAMPLE
;type _SesDParam $s r
;_SesDParam z
;z.s="A string Header"
;z.r=30 ;; Run for 30s
;if(!ShowDialog("Timer_progress_TT" &Timer_progress_TT 0 0 0 0 0 &z)) ret

def PBM_SETRANGE (WM_USER+1)
def PBM_SETPOS (WM_USER+2)
def PBM_DELTAPOS (WM_USER+3)

;BEGIN DIALOG
;0 "" 0x10C80A44 0x100 0 0 224 32 ""
;3 msctls_progress32 0x54000000 0x4 8 16 136 12 ""
;5 Static 0x54000000 0x0 148 16 26 12 ""
;6 Static 0x54800402 0x0 178 16 42 12 ""
;4 Static 0x54000000 0x0 8 2 134 10 "Time Period to run : : "
;END DIALOG
;DIALOG EDITOR: "" 0x2040308 "" "" "" ""

ret
;messages
_SesDParam& z=+DT_GetParam(hDlg)
int- ttime range timerperiod ti
ttime=z.r
int step=1

;int timerperiod=100 ;;should be >=50
timerperiod=iif(timerperiod<50 100 timerperiod)
str- header
header=z.s

int hpb=id(3 hDlg)
str sp st
long- t0

sel message
,case WM_INITDIALOG
,DT_Init(hDlg lParam)
,header.setwintext(hDlg)
,ont hDlg
;,Total time (sec) = range * 10 / timeperiod

,range=ttime*timerperiod/10
,outt F"{ttime} - {timerperiod} - {range}"

,str sest=F"Total Time Period to run (s) : {ttime}"
,
,sest.setwintext(id(4 hDlg))
,SendMessage hpb PBM_SETRANGE ti range<<16
,GetSystemTimeAsFileTime +&t0
,SetTimer hDlg 1 timerperiod 0

,ret 1
,
,case WM_TIMER
,ti+step
,SendMessage hpb PBM_SETPOS ti 0
,if(ti<range)
,,sp.format("%i %%" 100*ti/range)
,else
,,sp="Completed"
,,KillTimer hDlg 1
,,DT_Ok hDlg ;;close dialog
,sp.setwintext(id(5 hDlg))

,long t dt
,GetSystemTimeAsFileTime +&t
,t-t0
,st=ConvertTimeToString(t)
,st.setwintext(id(6 hDlg))

,case WM_DESTROY DT_DeleteData(hDlg)
,case WM_COMMAND goto messages2
ret
;messages2
int ctrlid=wParam&0xFFFF; message=wParam>>16
sel wParam
,case IDOK DT_Ok hDlg
,case IDCANCEL DT_Cancel hDlg
ret 1
#2
I have done several tests. I am afraid that the outcome is that SetTimer/WM_Timer does give accurate time. I am concluding that the answer is given in topic Presenting images.


Forum Jump:


Users browsing this thread: 1 Guest(s)