Don't pass 0 timer ids to ::SetTimer().
Creating timers with 0 id failed because Windows SetTimer() function requires a non-zero id. Fix this by using a (impossible at wx API level) -1 id value in this case instead. Closes #11392. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62977 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -105,12 +105,22 @@ bool wxMSWTimerImpl::Start(int milliseconds, bool oneShot)
|
|||||||
if ( !wxTimerImpl::Start(milliseconds, oneShot) )
|
if ( !wxTimerImpl::Start(milliseconds, oneShot) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_id = ::SetTimer(
|
// SetTimer() doesn't accept 0 timer id so use something else if the timer
|
||||||
wxTimerHiddenWindowModule::GetHWND(), // window to send the messages to
|
// id at wx level is 0: as -1 (wxID_ANY) can't be used, we can safely
|
||||||
GetId(), // timer ID
|
// replace 0 with it at MSW level
|
||||||
(UINT)m_milli, // delay
|
UINT idTimer = GetId();
|
||||||
NULL // timer proc. Not used since we pass hwnd
|
if ( !idTimer )
|
||||||
);
|
idTimer = (UINT)-1;
|
||||||
|
|
||||||
|
// SetTimer() normally returns just idTimer but this might change in the
|
||||||
|
// future so use its return value to be safe
|
||||||
|
m_id = ::SetTimer
|
||||||
|
(
|
||||||
|
wxTimerHiddenWindowModule::GetHWND(), // window for WM_TIMER
|
||||||
|
idTimer, // timer ID to create
|
||||||
|
(UINT)m_milli, // delay
|
||||||
|
NULL // timer proc (unused)
|
||||||
|
);
|
||||||
|
|
||||||
if ( !m_id )
|
if ( !m_id )
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user