定时器过程
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.386
.model flat, stdcall
option casemap :none
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; Include 文件定义
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include windows.inc
include user32.inc
includelib user32.lib
include kernel32.inc
includelib kernel32.lib
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; Equ 等值定义
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
IDD_DIALOG1 equ 101
IDC_IOSHOW equ 1000
IDC_IOFLOW equ 1001
IDC_EDIT equ 1002
ID_START equ 1003
ID_STOP equ 1004
ID_TIMER equ 2
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 数据段
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.data?
hInstance dd ?
hWinMain dd ?
hWinStart dd ?
hWinStop dd ?
idTimer dd ?
bRecentVal db ?
bShowVal db ?
F_RADIO dd ?
F_STOP equ 0001h
F_START equ 0002h
A_ADDR equ 0060h
.data
IO_PORT dw 0d000h
.const
szInit db '显示数字',0
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 代码段
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.code
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;定时器过程
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_ProcTimer proc _hWnd,_uMsg,_idEvent,_dwTime
pushad
mov dx,IO_PORT
in al,dx
.if F_RADIO == 2
and al,01h
.if al == bRecentVal
.if al == 0;from left to right
ror bShowVal,1
.else
rol bShowVal,1
.endif
.else
mov bRecentVal,al
.if al == 0
mov bShowVal,80h
.else
mov bShowVal,1h
.endif
.endif
mov al,bShowVal
.endif
out dx,al
movzx eax,al
invoke SetDlgItemInt,hWinMain,IDC_EDIT,eax,FALSE
popad
ret
_ProcTimer endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_ProcDlgMain proc uses ebx edi esi hWnd,wMsg,wParam,lParam
mov eax,wMsg
;********************************************************************
.if eax == WM_COMMAND
mov eax,wParam
.if ax == ID_START
.if F_RADIO ==1 || F_RADIO ==2
invoke SetTimer,NULL,NULL,1000,offset _ProcTimer
.if idTimer
invoke KillTimer,NULL,idTimer
.endif
mov idTimer,eax
invoke EnableWindow,hWinStart,FALSE
invoke EnableWindow,hWinStop,TRUE
.endif
.elseif ax == ID_STOP
invoke KillTimer,NULL,idTimer
invoke EnableWindow,hWinStop,FALSE
invoke EnableWindow,hWinStart,TRUE
.elseif ax == IDC_IOSHOW
invoke EnableWindow,hWinStart,TRUE
invoke EnableWindow,hWinStop,FALSE
mov F_RADIO,1
.elseif ax == IDC_IOFLOW
invoke EnableWindow,hWinStart,TRUE
invoke EnableWindow,hWinStop,FALSE
mov F_RADIO,2
.endif
;********************************************************************
.elseif eax == WM_CLOSE
invoke KillTimer,NULL,idTimer
invoke EndDialog,hWnd,NULL
;********************************************************************
.elseif eax == WM_INITDIALOG
push hWnd
pop hWinMain
invoke GetDlgItem,hWnd,ID_START
mov hWinStart,eax
invoke GetDlgItem,hWnd,ID_STOP
mov hWinStop,eax
add IO_PORT,A_ADDR
mov F_RADIO,0
mov idTimer,0
invoke SetDlgItemText,hWnd,IDC_EDIT,addr szInit
;********************************************************************
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret
_ProcDlgMain endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
start:
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke DialogBoxParam,eax,IDD_DIALOG1,NULL,offset _ProcDlgMain,NULL
invoke ExitProcess,NULL
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
end start
;***************************************************************************
怎么我的invoke SetTimer,NULL,NULL,1000,offset _ProcTimer
为什么这个基于过程的定时器不起作用
而设置基于窗口的定时器,
象SetTimer,hWnd,,idEvent,offset _ProcTimer这样就没有这样的问题
谁能看出来,程序哪里出毛病了吗!!!!!!!