开发环境:VS2008 + VC + MFC
如何让BUTTON在按下的状态下持续触发BN_CLICKED事件,除了使用定时器,还有什么方法?

解决方案 »

  1.   

    while()
    {
    ........
    Sleep()
    }
    可以吗
      

  2.   

    PreTranslateMessage(MSG* pMsg)WM_LBUTTONDOWN
    WM_LBUTTONUPexample:if (pMsg->message == WM_LBUTTONDOWN)
    {
    ......
    }
      

  3.   

    你重新CButton类,处理WM_LBUTTONDOWN/WM_LBUTTONUP消息不是更好?
      

  4.   

    监听MouseUp消息,只要没有就继续你的down
      

  5.   

    WM_LBUTTONDOWN
    WM_LBUTTONUP
      

  6.   

    void CMyButton::OnLButtonDown(UINT nFlags, CPoint point) 
    {
    // TODO: Add your message handler code here and/or call default
    SetTimer(1,100,0);
    CButton::OnLButtonDown(nFlags, point);
    }void CMyButton::OnLButtonUp(UINT nFlags, CPoint point) 
    {
    // TODO: Add your message handler code here and/or call default
    KillTimer(1);
    CButton::OnLButtonUp(nFlags, point);
    }void CMyButton::OnTimer(UINT nIDEvent) 
    {
    // TODO: Add your message handler code here and/or call default
    if(GetKeyState(VK_LBUTTON) & 0x8000)
    {
    GetParent()->SendMessage(WM_COMMAND,BN_CLICKED << 16 | GetDlgCtrlID());
    }
    CButton::OnTimer(nIDEvent);
    }
    不通过定时器会死循环