I have

invoke SetTimer, hWin, 1001, 30, 0
in WM_CREATE

and then

invoke KillTimer, hWin, 1001
in WM_TIMER

The timer keeps on ticking though.
Spy++ gives a timerid of 1 instead of 1001.

At a loss. Anything obviously wrong with the above code?
Posted on 2002-05-14 03:40:15 by grv575
tested and works fine for me. i even copy and pasted your code into my program. i checked with spy++ and my id is 1001. maybe you should try using a different id. test the code below and see if you come up with the same thing.
.586

.model flat, stdcall
option casemap :none

include /masm32/include/windows.inc
include /masm32/include/kernel32.inc
include /masm32/include/user32.inc
includelib /masm32/lib/kernel32.lib
includelib /masm32/lib/user32.lib

WinMain PROTO :DWORD,:DWORD,:DWORD,:DWORD
WndProc PROTO :DWORD,:DWORD,:DWORD,:DWORD
TopXY PROTO :DWORD,:DWORD

.data
ClassName db "Starting Template",0
CaptionText db "Template",0

.data?
hWnd HANDLE ?
hInstance HANDLE ?

.code
start:
invoke GetModuleHandle, NULL
mov hInstance, eax
invoke WinMain,hInstance,NULL,NULL,SW_SHOWDEFAULT
invoke ExitProcess,eax

; ######################################

WinMain proc hInst:DWORD, hPrevIns:DWORD, CmdLine:DWORD, CmdShow:DWORD

LOCAL wc :WNDCLASSEX
LOCAL msg :MSG
LOCAL Wwd :DWORD
LOCAL Wht :DWORD
LOCAL Wtx :DWORD
LOCAL Wty :DWORD

mov wc.cbSize, SIZEOF WNDCLASSEX
mov wc.style, CS_HREDRAW + CS_VREDRAW
mov wc.lpfnWndProc, OFFSET WndProc
mov wc.cbClsExtra, NULL
mov wc.cbWndExtra, NULL
mov eax, hInstance
mov wc.hInstance, eax
invoke LoadIcon, NULL,IDI_APPLICATION
mov wc.hIcon, eax
mov wc.hIconSm, eax
invoke LoadCursor, NULL,IDC_ARROW
mov wc.hCursor, eax
mov wc.hbrBackground,COLOR_BTNFACE+1
mov wc.lpszMenuName, NULL
mov wc.lpszClassName,OFFSET ClassName
invoke RegisterClassEx, addr wc

mov Wwd, 500
mov Wht, 350

invoke GetSystemMetrics,SM_CXSCREEN
invoke TopXY,Wwd,eax
mov Wtx, eax

invoke GetSystemMetrics,SM_CYSCREEN
invoke TopXY,Wht,eax
mov Wty, eax

invoke CreateWindowEx, NULL,
ADDR ClassName,
ADDR CaptionText,
WS_OVERLAPPEDWINDOW,
Wtx,Wty,Wwd,Wht,
NULL,
NULL,
hInst,
NULL
mov hWnd,eax
invoke ShowWindow,hWnd,SW_SHOWNORMAL
invoke UpdateWindow,hWnd

StartLoop:
invoke GetMessage,ADDR msg,NULL,0,0
cmp eax, 0
je ExitLoop
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
jmp StartLoop
ExitLoop:

mov eax,msg.wParam
ret

WinMain endp

; ########################################

WndProc proc hWin:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM

.IF uMsg == WM_CREATE
invoke SetTimer, hWin, 1001, 5000, 0


.elseif uMsg == WM_TIMER
invoke MessageBox,0,0,0,0
invoke KillTimer, hWin, 1001

.ELSEIF uMsg == WM_DESTROY
invoke PostQuitMessage,NULL
.ELSE
invoke DefWindowProc,hWin,uMsg,wParam,lParam
ret
.ENDIF
xor eax,eax
ret

WndProc endp


; #######################################

TopXY proc wDim:DWORD, sDim:DWORD

shr sDim, 1
shr wDim, 1
mov eax, wDim
sub sDim, eax
mov eax,sDim
ret

TopXY endp

; ########################################

end start
Posted on 2002-05-14 04:44:31 by smurf
Yeah my bad. It was a different timer altogether.
Posted on 2002-05-14 05:44:56 by grv575