1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxTimer implementation
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "timer.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
30 #include "wx/msw/private.h"
33 #include <sys/types.h>
35 #if !defined(__SC__) && !defined(__GNUWIN32__)
36 #include <sys/timeb.h>
41 #define _EXPORT _export
46 wxList
wxTimerList(wxKEY_INTEGER
);
47 UINT WINAPI _EXPORT
wxTimerProc(HWND hwnd
, WORD
, int idTimer
, DWORD
);
49 #if !USE_SHARED_LIBRARY
50 IMPLEMENT_ABSTRACT_CLASS(wxTimer
, wxObject
)
53 wxTimer::wxTimer(void)
60 wxTimer::~wxTimer(void)
64 wxTimerList
.DeleteObject(this);
67 bool wxTimer::Start(int milliseconds
,bool mode
)
71 milliseconds
= lastMilli
;
73 if (milliseconds
<= 0)
76 lastMilli
= milli
= milliseconds
;
78 wxTimerList
.DeleteObject(this);
79 TIMERPROC wxTimerProcInst
= (TIMERPROC
) MakeProcInstance((FARPROC
)wxTimerProc
,
82 id
= SetTimer(NULL
, (UINT
)(id
? id
: 1), (UINT
)milliseconds
, wxTimerProcInst
);
85 wxTimerList
.Append(id
, this);
91 void wxTimer::Stop(void)
94 KillTimer(NULL
, (UINT
)id
);
95 wxTimerList
.DeleteObject(this); /* @@@@ */
101 UINT WINAPI _EXPORT
wxTimerProc(HWND
WXUNUSED(hwnd
), WORD
, int idTimer
, DWORD
)
103 wxNode
*node
= wxTimerList
.Find((long)idTimer
);
106 wxTimer
*timer
= (wxTimer
*)node
->Data();
108 return(0) ; // Avoid to process spurious timer events