title: CButton : OnBnClicked() is called inexepectedly when SetState is used
body: <p>I want to click a button and shown it "pressed" until a timer has terminated.</p>
  
  <p>The problem I have is, wenn I use <a href="https://msdn.microsoft.com/en-us/library/ebw1hfe8.aspx" rel="nofollow"><code>CButton::SetState(TRUE)</code></a> the function <code>OnBnClickedButton1()</code> is called always twice and even worse it is called again when I press a another button in the dialog or hide the dialog window.</p>
  
  <p>(Update: I have now tested the same code at home under VS6 with WindowsXP, it works fine as expected. At work (VS2010 with Window 10) this code does not work.)</p>
  
  <p><strong>Header file</strong></p>
  
  <pre><code>class CTestDialog : public CDialog
  {
      CButton btnButton1;
  
      enum {eTimerCoolingId = 123};
      BOOL m_bCooling;
      DWORD m_dwStartTick;
      ...
  }
  </code></pre>
  
  <p><strong>CPP file</strong></p>
  
  <pre><code>...
  DDX_Control(pDX, IDC_BUTTON1, m_btnButton1);
  
  void CTestDialog::OnBnClickedButton1()
  {
      m_bCooling = !m_bCooling;
      m_btnButton1.SetState(m_bCooling);
      m_dwStartTick = GetTickCount();
  
      if (m_bCooling)
          SetTimer(eTimerCoolingId,100,NULL);
      else
          KillTimer(eTimerCoolingId);
  }
  
  void CTestDlg::OnTimer(UINT nIDEvent) 
  {
      int nCoolTime = 5;  // [sec]
      CString str;
  
      switch(nIDEvent)
      {
      case eTimerCoolingId:
  
          int nElapsedTime = (GetTickCount() - m_dwStartTick) / 1000;
          if (nElapsedTime &gt; nCoolTime)
          {
              KillTimer(eTimerCoolingId);
              m_bCooling = false;
              m_btnButton1.SetState(FALSE);
              str.Format("Cooler On");
          }
          else
          {
              str.Format("Cooling.. %d [sec]", (nCoolTime - nElapsedTime));
          }
      }
  
     m_btnButton1.SetWindowText(str);
     CDialog::OnTimer(nIDEvent);
  }
  </code></pre>