News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

I think my timer is screwing up.

Started by Ash_, February 07, 2006, 01:18:32 PM

Previous topic - Next topic

Ash_


WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
LOCAL pt:POINT
.if uMsg==WM_CREATE
invoke CreatePopupMenu
mov hPopupMenu,eax
invoke AppendMenu,hPopupMenu,MF_STRING,IDM_RESTORE,addr RestoreString
invoke AppendMenu,hPopupMenu,MF_STRING,401,addr ChangeIconString
            invoke AppendMenu,hPopupMenu,MF_STRING,402,addr DownloadString
            invoke AppendMenu,hPopupMenu,MF_STRING,403,addr ReadFileString
            invoke AppendMenu,hPopupMenu,MF_STRING,IDM_EXIT,addr ExitString


.if set==0
invoke SetTimer,hWnd,1,5000,NULL
mov set,1

.endif

       .elseif uMsg==WM_TIMER


             mov ecx,wParam

            .IF ecx==1         ;First Condition

            call DownloadFile
           call GetFileContent
           call CheckServer
            .ENDIF



thats pretty much all the code involving timers, i look at the Mem. usage and goes to about 5k. if i put a message box in anyone of those 3 fucntions (DownloadFile,GetFileContent and CheckServer), it starts off as one message box, then two then three etc. how do you stop this from happening? i tried putting a kill timer call after the function calls but to no avail. thansk in advance.

Human

first of all you dont need that check
.if set==0
invoke SetTimer,hWnd,1,5000,NULL
mov set,1
just put invoke in wm_create due its called once and will set timer

you code is wrong due if you set timer to 5s and will wait 15s in messagebox then it should catch 3x wm_timer
to show just one messagebox
you can use marker
if donemessage
   mov donemessage,1
   call DownloadFile
           call GetFileContent
           call CheckServer
   mov donemessage,0
endif
and it will just work 1 time if wm_timer is called more times if we still do our autosave or autodownload
if it doesnt work then read here
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/waitable_timer_objects.asp
there you can manualy restart timer because wm_timer will be called even if you havent finished last one