win32汇编定时器简单Demo
生活随笔
收集整理的這篇文章主要介紹了
win32汇编定时器简单Demo
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
timer.asm;
.386.model flat,stdcalloption casemap:noneinclude windows.inc include user32.inc includelib user32.lib include kernel32.inc includelib kernel32.libID_TIMER1 equ 1 ICO_1 equ 1 DLG_MAIN equ 1.data? hInstance dd ? hWinMain dd ? idTimer dd ?.const szCaption db '定時(shí)器簡單demo',0 szReturn db '收到定時(shí)器消息',0.code ; 定時(shí)器過程 _ProcTimer procret _ProcTimer endp_ProcDlgMain proc uses ebx edi esi,hWnd,uMsg,wParam,lParammov eax,uMsg.if eax == WM_TIMERmov eax,wParam.if eax == ID_TIMER1invoke MessageBox,NULL,offset szReturn,offset szCaption,MB_OK.endif.elseif eax == WM_INITDIALOGpush hWndpop hWinMaininvoke SetTimer,hWnd,ID_TIMER1,3000,NULLinvoke SetTimer,NULL,NULL,1000,addr _ProcTimermov idTimer,eax.elseif eax == WM_CLOSEinvoke KillTimer,hWnd,ID_TIMER1invoke EndDialog,hWnd,NULL.elsemov eax,FALSEret.endifmov eax,TRUEret _ProcDlgMain endpstart:invoke GetModuleHandle,NULLmov hInstance,eaxinvoke DialogBoxParam,hInstance,DLG_MAIN,NULL,offset _ProcDlgMain,NULLinvoke ExitProcess,NULLend starttimer.rc;
#include <resource.h>#define DLG_MAIN 1 #define ICO_1 1ICO_1 ICON "1.ico"DLG_MAIN DIALOG 800, 500, 100, 100 STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU CAPTION "定時(shí)器Demo" FONT 9, "宋體" {ICON ICO_1, -1, 00, 10, 25, 25 }_ProcTimer?? ?proc
?? ??? ?ret
_ProcTimer?? ?endp
一個(gè)定時(shí)器過程,啥也不干,直接返回;
?
?invoke?? ?MessageBox,NULL,offset szReturn,offset szCaption,MB_OK
主窗收到定時(shí)器消息彈出一個(gè)消息框;
?invoke?? ?SetTimer,hWnd,ID_TIMER1,3000,NULL
invoke?? ?SetTimer,NULL,NULL,1000,addr _ProcTimer
設(shè)置定時(shí)器,設(shè)置了以后主窗會(huì)收到WM_TIMER消息;也可給定時(shí)器設(shè)置定時(shí)器過程,在里面做些動(dòng)作;
構(gòu)建,運(yùn)行,如下;
?
資源文件中,
? ? ICON ICO_1, -1, 00, 10, 25, 25
這一句,00 和 10、25、25是圖標(biāo)放在對(duì)話框的位置和大小;前面有個(gè)-1;使用 -1 ,程序自己裝載圖標(biāo),不用LoadIcon;如缺前面的-1,則出錯(cuò)如下;?
?
總結(jié)
以上是生活随笔為你收集整理的win32汇编定时器简单Demo的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: win32汇编创建线程简单Demo
- 下一篇: matlab input函数学习