News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Progressbar starts ok - but why and how

Started by clamicun, December 16, 2014, 05:07:38 AM

Previous topic - Next topic

clamicun

;.486
;.model flat,stdcall
;option casemap:none

include \masm32\include\masm32rt.inc
     
.data

box1 TCHAR 'Box1',0
box2 TCHAR 'Box2',0
hProgress1 dd ?
stop_PB1   dw ?
   
hProgress2 dd ?
stop_PB2   dw ?
whandle1   dd ?
whandle2   dd ?
threadID   dd ?

.code
start:

mov stop_PB1,FALSE
mov stop_PB2,FALSE

mov  eax,OFFSET create_dialog2
invoke CreateThread,NULL,NULL,eax, NULL,NORMAL_PRIORITY_CLASS,NULL
mov threadID,eax

call create_dialog1
;call create_dialog2   ?????

INVOKE ExitProcess,eax

;----------
create_dialog1 proc

Dialog  "Searching1...", \
"MS Sans Serif",8,\
DS_ABSALIGN,\
1,\
100,200,100,12,1024                           

DlgProgress ' ',0,0,100,12 ,102  ;PBS_SMOOTH
   
INVOKE GetModuleHandle, NULL
CallModalDialog eax,0,DlgProc1,0

ret

create_dialog1 endp
;----------

DlgProc1 proc hWin1:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
push hWin1
pop whandle1

Switch uMsg

Case WM_INITDIALOG
 
mov hProgress1, rv(GetDlgItem,whandle1,102)
INVOKE SetTimer,whandle1,0,0,0            ;This is a fake, because I don't know which other WM_ to use...

Case WM_TIMER   
                   
INVOKE SendMessage,hProgress1,PBM_SETRANGE32,1,30
INVOKE KillTimer,whandle1,0               ;???

.while stop_PB1 != TRUE     
 
xor esi, esi
reset:
INVOKE SendMessage,hProgress1,PBM_SETPOS,esi,0
INVOKE SleepEx,10,0
add esi, 1
cmp esi, 100
jb reset

.endw

INVOKE EndDialog,whandle1,0
                               
endsw
         
return 0    ;???
;ret
   
DlgProc1 endp


;----------
create_dialog2 proc

Dialog  "Searching2...", \
"MS Sans Serif",8,\
DS_ABSALIGN,\
1,\
220,200,100,12,1024                           

DlgProgress ' ',0,0,100,12 ,103  ;PBS_SMOOTH
   
INVOKE GetModuleHandle, NULL
CallModalDialog eax,0,DlgProc2,0

mov stop_PB1,TRUE
INVOKE CloseHandle,threadID
ret

create_dialog2 endp
;----------

DlgProc2 proc hWin2:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
push hWin2
pop whandle2

Switch uMsg

Case WM_INITDIALOG
 
mov hProgress2, rv(GetDlgItem,whandle2,103)
INVOKE SetTimer,whandle2,0,0,0            ;This is a fake, because I don't know which other WM_ to use...

Case WM_TIMER
                   
INVOKE SendMessage,hProgress2,PBM_SETRANGE32,1,30
;INVOKE KillTimer,whandle2,0
               
.while stop_PB2 != 5

xor esi, esi
reset:
INVOKE SendMessage,hProgress2,PBM_SETPOS,esi,0
INVOKE SleepEx,10,0
add esi, 1
cmp esi, 100
jb reset
inc stop_PB2

.endw

INVOKE EndDialog,whandle2,0
                               
endsw
         
return 0    ;???

;ret   
DlgProc2 endp

;----------

end start