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"
27 #include "wx/window.h"
37 #include "wx/msw/private.h"
39 // ----------------------------------------------------------------------------
41 // ----------------------------------------------------------------------------
43 wxList
wxTimerList(wxKEY_INTEGER
);
44 UINT WINAPI _EXPORT
wxTimerProc(HWND hwnd
, WORD
, int idTimer
, DWORD
);
46 // ----------------------------------------------------------------------------
48 // ----------------------------------------------------------------------------
53 #define _EXPORT _export
56 IMPLEMENT_ABSTRACT_CLASS(wxTimer
, wxObject
)
58 // ============================================================================
60 // ============================================================================
62 // ----------------------------------------------------------------------------
64 // ----------------------------------------------------------------------------
75 wxTimerList
.DeleteObject(this);
78 bool wxTimer::Start(int milliseconds
, bool oneShot
)
80 (void)wxTimerBase::Start(milliseconds
, oneShot
);
82 wxCHECK_MSG( m_milli
> 0, FALSE
, wxT("invalid value for timer timeour") );
84 wxTimerList
.DeleteObject(this);
85 TIMERPROC wxTimerProcInst
= (TIMERPROC
)
86 MakeProcInstance((FARPROC
)wxTimerProc
, wxGetInstance());
88 m_id
= SetTimer(NULL
, (UINT
)(m_id
? m_id
: 1),
89 (UINT
)milliseconds
, wxTimerProcInst
);
92 wxTimerList
.Append(m_id
, this);
98 wxLogSysError(_("Couldn't create a timer"));
108 KillTimer(NULL
, (UINT
)m_id
);
109 wxTimerList
.DeleteObject(this);
115 // ----------------------------------------------------------------------------
117 // ----------------------------------------------------------------------------
119 void wxProcessTimer(wxTimer
& timer
)
121 // Avoid to process spurious timer events
122 if ( timer
.m_id
== 0)
125 if ( timer
.IsOneShot() )
131 UINT WINAPI _EXPORT
wxTimerProc(HWND
WXUNUSED(hwnd
), WORD
, int idTimer
, DWORD
)
133 wxNode
*node
= wxTimerList
.Find((long)idTimer
);
135 wxCHECK_MSG( node
, 0, wxT("bogus timer id in wxTimerProc") );
137 wxProcessTimer(*(wxTimer
*)node
->Data());
142 #endif // wxUSE_TIMER