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"
25 #include "wx/window.h"
35 #include "wx/msw/private.h"
37 // ----------------------------------------------------------------------------
39 // ----------------------------------------------------------------------------
41 wxList
wxTimerList(wxKEY_INTEGER
);
42 UINT WINAPI _EXPORT
wxTimerProc(HWND hwnd
, WORD
, int idTimer
, DWORD
);
44 // ----------------------------------------------------------------------------
46 // ----------------------------------------------------------------------------
51 #define _EXPORT _export
54 IMPLEMENT_ABSTRACT_CLASS(wxTimer
, wxObject
)
56 // ============================================================================
58 // ============================================================================
60 // ----------------------------------------------------------------------------
62 // ----------------------------------------------------------------------------
73 wxTimerList
.DeleteObject(this);
76 bool wxTimer::Start(int milliseconds
, bool oneShot
)
78 (void)wxTimerBase::Start(milliseconds
, oneShot
);
80 wxCHECK_MSG( m_milli
> 0, FALSE
, wxT("invalid value for timer timeour") );
82 wxTimerList
.DeleteObject(this);
83 TIMERPROC wxTimerProcInst
= (TIMERPROC
)
84 MakeProcInstance((FARPROC
)wxTimerProc
, wxGetInstance());
86 m_id
= SetTimer(NULL
, (UINT
)(m_id
? m_id
: 1),
87 (UINT
)milliseconds
, wxTimerProcInst
);
90 wxTimerList
.Append(m_id
, this);
96 wxLogSysError(_("Couldn't create a timer"));
106 KillTimer(NULL
, (UINT
)m_id
);
107 wxTimerList
.DeleteObject(this);
113 // ----------------------------------------------------------------------------
115 // ----------------------------------------------------------------------------
117 void wxProcessTimer(wxTimer
& timer
)
119 // Avoid to process spurious timer events
120 if ( timer
.m_id
== 0)
123 if ( timer
.IsOneShot() )
129 UINT WINAPI _EXPORT
wxTimerProc(HWND
WXUNUSED(hwnd
), WORD
, int idTimer
, DWORD
)
131 wxNode
*node
= wxTimerList
.Find((long)idTimer
);
133 wxCHECK_MSG( node
, 0, wxT("bogus timer id in wxTimerProc") );
135 wxProcessTimer(*(wxTimer
*)node
->Data());