+bool wxTimer::Start(int milliseconds, bool oneShot)
+{
+ (void)wxTimerBase::Start(milliseconds, oneShot);
+
+ wxCHECK_MSG( m_milli > 0, false, wxT("invalid value for timer timeout") );
+
+ m_id = ::SetTimer
+ (
+ NULL, // don't use window
+ 1, // id ignored with NULL hwnd anyhow
+ (UINT)m_milli, // delay
+ wxTimerProc // timer proc to call
+ );
+
+ if ( !m_id )
+ {
+ wxLogSysError(_("Couldn't create a timer"));
+
+ return false;
+ }
+
+ // check that SetTimer() didn't reuse an existing id: according to the MSDN
+ // this can happen and this would be catastrophic to us as we rely on ids
+ // uniquely identifying the timers because we use them as keys in the hash
+ if ( TimerMap().find(m_id) != TimerMap().end() )
+ {
+ wxLogError(_("Timer creation failed."));
+
+ ::KillTimer(NULL, m_id);
+ m_id = 0;
+
+ return false;
+ }
+
+ TimerMap()[m_id] = this;
+
+ return true;