Click here to Skip to main content
15,888,113 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hello Everyone,

I have a slider control which is used to control the value of the Bar chart. On moving the slider the Bar chart gets updated to new value. But I am facing one problem in the process. When the Arrow keys of keyboard are pressed continuously then bar chart takes time to update. I am not allowed to make changes in bar chart control so I have to handle the following events:
TB_LINEUP, TB_LINEDOWN, TB_TOP, TB_BOTTOM . like put some kind of timer or disable the events for some milliseconds. Please help me out.

Right now I am handling the events in switch case.


C#
void CSensorGain::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
    // TODO: Add your message handler code here and/or call default

    CString szBuffer;
    char cBuff[20] = {0};
    int nTemp = 0;
    int nCurrentPos = 0;

    if (IDC_SENSORGAIN_GAPMODESLIDER == pScrollBar->GetDlgCtrlID())
    {
        switch (nSBCode)
        {
            case TB_LINEUP:
                nCurrentPos = m_GapModeSlider.GetPos();
                SendSensorGainCommand(nCurrentPos);                
                break;

            case TB_LINEDOWN:
                nCurrentPos = m_GapModeSlider.GetPos();
                SendSensorGainCommand(nCurrentPos);
                break;

            case TB_PAGEUP:
                nTemp = m_GapModeSlider.GetPos();
                m_GapModeSlider.SetPos(nTemp);
                break;

            case TB_PAGEDOWN:
                nTemp = m_GapModeSlider.GetPos();
                m_GapModeSlider.SetPos(nTemp);
                break;

            case TB_TOP:
                nCurrentPos = m_GapModeSlider.GetPos();
                SendSensorGainCommand(nCurrentPos);
                break;

            case TB_BOTTOM:
                nCurrentPos = m_GapModeSlider.GetPos();
                SendSensorGainCommand(nCurrentPos);
                break;

            default:
                break;
        }
        return ;
    }

    CDialogEx::OnHScroll(nSBCode, nPos, pScrollBar);
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900