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
44 wxList
wxTimerList(wxKEY_INTEGER
);
45 UINT WINAPI _EXPORT
wxTimerProc(HWND hwnd
, WORD
, int idTimer
, DWORD
);
47 #if !USE_SHARED_LIBRARY
48 IMPLEMENT_ABSTRACT_CLASS(wxTimer
, wxObject
)
51 wxTimer::wxTimer(void)
58 wxTimer::~wxTimer(void)
62 wxTimerList
.DeleteObject(this);
65 bool wxTimer::Start(int milliseconds
,bool mode
)
69 milliseconds
= lastMilli
;
71 if (milliseconds
<= 0)
74 lastMilli
= milli
= milliseconds
;
76 wxTimerList
.DeleteObject(this);
77 TIMERPROC wxTimerProcInst
= (TIMERPROC
) MakeProcInstance((FARPROC
)wxTimerProc
,
80 id
= SetTimer(NULL
, (UINT
)(id
? id
: 1), (UINT
)milliseconds
, wxTimerProcInst
);
83 wxTimerList
.Append(id
, this);
89 void wxTimer::Stop(void)
92 KillTimer(NULL
, (UINT
)id
);
93 wxTimerList
.DeleteObject(this); /* @@@@ */
99 UINT WINAPI _EXPORT
wxTimerProc(HWND
WXUNUSED(hwnd
), WORD
, int idTimer
, DWORD
)
101 wxNode
*node
= wxTimerList
.Find((long)idTimer
);
104 wxTimer
*timer
= (wxTimer
*)node
->Data();
106 return(0) ; // Avoid to process spurious timer events