;<ff
Window dlgProgress, 3, 0, 'TForm', '', $0, $10080, 0, 233, 236, 216, 96, 0;
Window NONE, 0, 0, 'BUTTON', 'Cancel', $50010001, $0, 2, 76, 43, 64, 20, 0;
Window NONE, 2, 0, 'msctls_progress32', '', $50000001, $0, 100, 8, 12, 192, 19, 0;
;ff>
uglobal
hProgressWnd dd ?
endg
; creates progress window and returns its handle in ebx (also hProgressWnd variable is set)
; hwnd_progress variable is set to progressbar's handle
; arguments:
; p_max - maximum value of progressbar
; p_step - on each step progressbar will be increased by this value
; caption - pointer or handle to string containing progress window's caption
; no_cancel_btn - if set to 1, "cancel" button won't appear in the window
proc ProgressWndCreate, .p_max, .p_step, .caption, .no_cancel_btn
.rect RECT
begin
push esi edi
stdcall CreateForm, dlgProgress, [hEditorsHost]
mov [hProgressWnd], ebx
stdcall SetControlTextUtf8, ebx, [.caption]
mov eax,[.p_max]
shl eax,16
invoke SendDlgItemMessageW, [hProgressWnd], 100, PBM_SETRANGE, 0, eax
xor eax,eax
invoke SendDlgItemMessageW, [hProgressWnd], 100, PBM_SETPOS, eax, eax
invoke SendDlgItemMessageW, [hProgressWnd], 100, PBM_SETSTEP, 1, eax
lea eax, [.rect]
invoke GetWindowRect, [hProgressWnd], eax
invoke GetSystemMetrics, SM_CXSCREEN
sub eax, [.rect.right]
add eax, [.rect.left]
sar eax,1
mov esi, eax
invoke GetSystemMetrics, SM_CYSCREEN
sub eax, [.rect.right]
add eax, [.rect.left]
sar eax,1
mov edi, eax
mov eax,96
cmp [.no_cancel_btn],1
jne @f
mov eax,64
@@:
invoke SetWindowPos, [hProgressWnd],HWND_TOP,esi,edi,216,eax,0
pop edi esi
return
endp
; destroys progress window
proc ProgressWndDestroy
begin
invoke DestroyWindow, [hProgressWnd]
mov [hProgressWnd], 0
return
endp
; increases value of progressbar in progress window
proc ProgressWndStepIt
begin
pushad
invoke SendDlgItemMessageW, [hProgressWnd], 100, PBM_STEPIT, 0, 0
popad
return
endp