📄 jacts.asm
字号:
invoke EnableWindow, rab_handle, TRUE
invoke SendMessage, rab_handle, BM_SETCHECK, 1, 0
.endif
invoke SendMessage, cdtb_handle, BM_SETCHECK, 1, 0 ;click the Countdown Timer button
invoke EnableWindow, sdc_handle, FALSE ;disable the DateTime control
invoke SetFocus, mc_handle ;set focus to Minute listbox
.endif
.elseif (iMsg == WM_CLOSE)
invoke EndDialog, hWnd, NULL
.elseif (iMsg == WM_COMMAND)
mov eax, wParam
mov edx, eax
shr edx, 16
.if (dx == BN_CLICKED) ;If button is clicked
.if (eax == IDC_AB) ;Alarm radio button pressed
mov def_acorr, 'A'
invoke SendMessage, ab_handle, BM_CLICK, 0, 0
invoke SetFocus, sdc_handle
invoke EnableWindow, rab_handle, FALSE
invoke EnableWindow, sc_handle, FALSE ;disable second listbox
invoke EnableWindow, mc_handle, FALSE
invoke EnableWindow, hc_handle, FALSE
invoke EnableWindow, sdc_handle, TRUE
.elseif (eax == IDC_CDTB) ;Countdown timer button pressed
invoke EnableWindow, rab_handle, TRUE
invoke EnableWindow, sc_handle, TRUE ;enable second listbox
invoke EnableWindow, mc_handle, TRUE
invoke EnableWindow, hc_handle, TRUE
invoke SendMessage, rab_handle, BM_GETCHECK, 0, 0
;determine if Repeat After button is pushed
.if( eax ) ;Repeat After CountDown Checked
mov def_acorr, 'R'
.else
mov def_acorr, 'C'
.endif
invoke SetFocus, mc_handle
invoke EnableWindow, sdc_handle, FALSE
.elseif (eax == IDC_SW) ;StopWatch button pressed
mov def_acorr, 'S'
invoke EnableWindow, rab_handle, FALSE
invoke EnableWindow, sc_handle, FALSE
invoke EnableWindow, mc_handle, FALSE
invoke EnableWindow, hc_handle, FALSE
invoke EnableWindow, sdc_handle, FALSE
.elseif (eax == IDC_PICK) ;Pick .wav sound button pressed
mov ofn.lStructSize,sizeof ofn
push hWnd
pop ofn.hWndOwner
push hInstance
pop ofn.hInstance
mov ofn.lpstrFilter, OFFSET FilterString
mov ofn.lpstrFile, OFFSET wav_name
mov ofn.nMaxFile, MAX_PATH
mov ofn.Flags, OFN_FILEMUSTEXIST or \
OFN_PATHMUSTEXIST or OFN_LONGNAMES or\
OFN_EXPLORER or OFN_HIDEREADONLY
mov ofn.lpstrTitle, OFFSET OurTitle
invoke GetOpenFileName, addr ofn
.if (eax==TRUE) ;valid name retrieved
invoke set_ini, 2, hWnd ;Save new .wav file name
.endif
.elseif (eax == IDC_START)
.if (def_acorr == 'S') ;Stop Watch
invoke ShowWindow, start_handle, SW_HIDE
invoke ShowWindow, stop_handle, SW_RESTORE
invoke ShowWindow, cancel_handle, SW_HIDE
invoke EnableWindow, cancel_handle, FALSE
invoke ShowWindow, lap_handle, SW_RESTORE
.endif
invoke start_timer, hWnd
.elseif (eax == IDC_STOP)
invoke ShowWindow, stop_handle, SW_HIDE
invoke ShowWindow, start_handle, SW_RESTORE
invoke ShowWindow, lap_handle, SW_HIDE
invoke ShowWindow, cancel_handle, SW_RESTORE
invoke EnableWindow, cancel_handle, TRUE
invoke KillTimer, hWnd, timer_handle
mov def_acorr, 'P' ;stopped stopwatch
call recalc
invoke update_display, hWnd
invoke ShowWindow, hWnd, SW_RESTORE
invoke SetForegroundWindow, hWnd
invoke EnableWindow, start_handle, TRUE
invoke EnableWindow, ab_handle, TRUE
invoke EnableWindow, sw_handle, TRUE
invoke EnableWindow, cdtb_handle, TRUE
invoke SendMessage, hWnd, DM_SETDEFID, IDC_CANCEL, 0
invoke SetFocus, cancel_handle
invoke SetWindowText, hWnd, addr AppName
mov def_acorr, 'S'
.elseif (eax == IDC_LAP)
mov def_acorr, 'P' ;stopped stopwatch
mov p_cnt, 0
call recalc
invoke update_display, hWnd
.elseif (eax == IDC_CANCEL)
invoke EndDialog,hWnd,NULL
.endif
.endif
.elseif (iMsg == WM_NOTIFY)
MOV eax,lParam ;lParam is a pointer to a NMHDR Struct
MOV eax, (NMHDR PTR [eax]).code ; is the code member a NM_SETFOCUS?
.if (eax == NM_SETFOCUS) ; If so, make sure time value is at least 1 minute beyond current time
invoke GetLocalTime, addr system_time ;Get current time
add system_time.wMinute, 1 ;add 1 to minutes
invoke SendMessage, sdc_handle, DTM_SETSYSTEMTIME, NULL, addr system_time
;set the control time to this updated time
.endif
.elseif (iMsg == WM_TIMER)
.if (def_acorr == 'P') ;If we are in lap function or stop
add p_cnt, 1 ;pause the display for 2 seconds
.if (p_cnt >= 2) ;by adding 1 to p_cnt until = 2
mov p_cnt, 0 ;reset counter
mov def_acorr, 'S' ;set to Stopwatch function to resume timing
jmp @F ;restart display
.endif
ret
.endif
mov is_zero, 0 ;check if timer has zeroed out
@@: call recalc ;tseconds holds # of seconds left
invoke update_display, hWnd ;update staus and title bar
.if (def_acorr == 'S') ;if stopwatch function
ret ;don't worry about timer expiration
.endif
cmp tseconds.dwLowDateTime, 0 ;check for zero in low order DWORD or tseconds
.if (ZERO?) ;if this is zero
mov is_zero, 1 ;remember
.endif
cmp tseconds.dwHighDateTime, 0 ;finish the subtraction from above
.if !(ZERO? && is_zero) ;if tseconds is != 0
ret ;keep counting
.endif
invoke ShowWindow, hWnd, SW_RESTORE ;if tseconds is == 0
invoke SetForegroundWindow, hWnd ;restore dialog
invoke PlaySound, addr wav_name, 0, SND_ASYNC or SND_NODEFAULT or SND_FILENAME
.if (def_acorr == 'A') ;If we just finished an alarm function
invoke KillTimer, hWnd, timer_handle ;stop timer
invoke MessageBox, hWnd, addr time_up, addr AppName, MB_OK ;display MessageBox
invoke EnableWindow, ab_handle, TRUE ;reenable buttons
invoke EnableWindow, cdtb_handle, TRUE
invoke EnableWindow, start_handle, TRUE
invoke EnableWindow, sw_handle, TRUE
invoke EnableWindow, sdc_handle, TRUE ;reenable DateTime control
invoke SetWindowText, hWnd, addr AppName
invoke SendMessage, hWnd, DM_SETDEFID, IDC_CANCEL, 0
invoke SetFocus, cancel_handle
.else ;If we just finished a Countdown Timer function
.if (def_acorr == 'R') ;Should we repeat countdown
mov eax, repeat_mins ;reload # of mins for countdown
mov eax, repeat_secs ;reload # of mins for countdown
mov ebx, 10000000 ;conversion for minutes to filetime units
mul ebx ;edx:eax holds filetime units to be added to time_now
add alarm_time.dwLowDateTime, eax ;add to original alarm time low order DWORD
adc alarm_time.dwHighDateTime, edx ;high order DWORD
call recalc
invoke update_display, hWnd
.if (mb_up == 0) ;Is the Timer Expiration MB already up
mov mb_up, 1 ;If not, do it now
invoke MessageBox, hWnd, addr time_up, addr AppName, MB_OK
mov mb_up, 0 ;When we return clear flag
.endif
.else ;No repeat countdown
invoke KillTimer, hWnd, timer_handle ;kill Timer
invoke MessageBox, hWnd, addr time_up, addr AppName, MB_OK
invoke EnableWindow, ab_handle, TRUE ;reenable buttons
invoke EnableWindow, cdtb_handle, TRUE
invoke EnableWindow, start_handle, TRUE
invoke EnableWindow, sw_handle, TRUE
invoke EnableWindow, rab_handle, TRUE ;reenable checkbox
invoke EnableWindow, sc_handle, TRUE ;reenable listboxes
invoke EnableWindow, mc_handle, TRUE
invoke EnableWindow, hc_handle, TRUE
invoke SendMessage, hWnd, DM_SETDEFID, IDC_CANCEL, 0
invoke SetFocus, cancel_handle
invoke SetWindowText, hWnd, addr AppName
.endif
.endif
.else
mov eax, FALSE
ret
.endif
mov eax, TRUE
ret
DlgProc endp
;-----------------------------------------------------
populate_lists PROC
;____________________________________________________________________
LOCAL z_str:BYTE ;Byte to hold a 0 'end of string'
LOCAL in_side:BYTE ;Byte for inside loop, 1's
LOCAL out_side:BYTE ;Byte for the outside loop, 10's
mov in_side, '0' ;initialize 1's
mov out_side, '0' ;initialize 10's
mov z_str, 0 ;set end of string
an_os: ;do another 10's
cmp out_side, '5' ;max value for 10's
jg dpl ;if done, jump to done populating list
an_is: ;do another 1's
cmp in_side, '9' ;max value for 1's
jg dis ;if done, jump to do inside
invoke SendMessage, hc_handle, CB_ADDSTRING, 0, addr out_side
;add to hour list
invoke SendMessage, mc_handle, CB_ADDSTRING, 0, addr out_side
;add to minute list
invoke SendMessage, sc_handle, CB_ADDSTRING, 0, addr out_side
;add to second list
inc in_side ;increment 1's
jmp an_is ;jump to another inside, 1's
dis:
inc out_side ;increment 10's
mov in_side, '0' ;reset 1's
jmp an_os ;jump to another outside, 10's
dpl: ;done populating list
ret
populate_lists ENDP
;-----------------------------------------------------
start_timer PROC hWnd:HWND
; Timer used in this program simply to update display of the dialog.
; Originally tried to use timer as counting mechanism, but quickly
; saw that timer gets 'distacted' by the doing other things and
; timer function would not 'fire' every 1000 milliseconds.
;_____________________________________________________
LOCAL st_hour:WORD
LOCAL st_min:WORD
LOCAL st_sec:WORD
LOCAL timer_min:DWORD
LOCAL timer_sec:DWORD
;For both Alarm and Countdown Timer, we will calculate expiration time
; For Alarm, this will be the value returned by DTM_GETSYSTEMTIME message
; For Countdown Timer, we will add the number of hours & minutes to the
; GetLocalTime value to get expiration time.
; Each time a Timer event is triggered, the number of remaining seconds
; will be recalculated. Expiration - GetLocalTime and stored in
; alarm_time FILETIME structure
; time_now FILETIME holds the current time
;For StopWatch, we will set the time_now and reset the alarm_time each
; timer event ~1 sec., the display will be updated by subtracting
; time_now (starting_time) from the alarm_now to calculate elapsed time!
;
invoke GetLocalTime, addr system_time ;Get Local Time
invoke SystemTimeToFileTime, addr system_time, addr time_now
;convert that system time into a file time to make comparison easier
invoke SendMessage, ab_handle, BM_GETCHECK, 1, 0 ;find out if Alarm Button is selected
.if (eax) ;Alarm Button is Selected
invoke SendMessage, sdc_handle, DTM_GETSYSTEMTIME, 0, addr system_time
;get the date time from that control
mov system_time.wSecond, 0 ;zero out the seconds
mov system_time.wMilliseconds, 0 ;and milliseconds
invoke SystemTimeToFileTime, addr system_time, addr alarm_time
;convert to filetime for comparison
mov eax, alarm_time.dwHighDateTime
sub eax, time_now.dwHighDateTime ;subtract time now from DT time
jb er_td ;quit if alarm.high < now.high
jne @F ;jump if alarm.high > now.high
mov eax, alarm_time.dwLowDateTime ;here if alarm.high = now.high
sub eax, time_now.dwLowDateTime
jb er_td ;quit if alarm.low < now.low
;Subtract Time_Now from Alarm_time to calculate the number of seconds to time
@@: mov eax, 1000 ;timer trips every second
invoke SetTimer, hWnd, timer_num, eax, NULL ;start timer
mov timer_handle, eax
mov def_acorr, 'A'
call recalc
invoke update_display, hWnd
invoke set_ini, 1, hWnd ;save the current settings
invoke EnableWindow, ab_handle, FALSE ;disable buttons
invoke EnableWindow, cdtb_handle, FALSE
invoke EnableWindow, rab_handle, FALSE
invoke EnableWindow, sw_handle, FALSE
invoke EnableWindow, start_handle, FALSE
invoke EnableWindow, sc_handle, FALSE ;disable listboxes
invoke EnableWindow, mc_handle, FALSE
invoke EnableWindow, hc_handle, FALSE
invoke EnableWindow, sdc_handle, FALSE ;disable DT controls
ret
er_td:
invoke MessageBox, hWnd, addr date_error, NULL, MB_OK
;report DateTime error
ret
.else ;Countdown timer Button or StopWatch checked
invoke SendMessage, sw_handle, BM_GETCHECK, 1, 0 ;find out if StopWatch button is selected
.if (eax) ;StopWatch function
mov eax, 1000
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -