I can't post the whole application, but here is a simplified version of it. I capture the mouse down and mouse up events and set the m_bMouseIsDown flag appropriately.
I basically just creep the pointer along until I get to the proper point. The problem is this callback happens after the pointer is painted at the new position. m_lpControlKnob is a pointer to the slider.
Eric
#define CHECK_FOR_PARENT_MESSAGES(hwnd) MSG msg;\
while(::PeekMessage(&msg, hwnd,0,0,PM_REMOVE))\
{TranslateMessage(&msg);DispatchMessage(&msg);}
#define LOOP_DELAY_MS (20)
void CCMCSimulatorDlg::OnPointerValueChangedLF(long Pointer, VARIANT FAR* Value)
{
static double lastVal = 0;
double valueDiff = Value->dblVal - lastVal;
double rateDirection = (fabs(valueDiff)/valueDiff);
double maxRateChange = 10;
maxRateChange = maxRateChange * LOOP_DELAY_MS/1000;
DWORD dwStart = GetTickCount();
DWORD dwDelayed = dwStart;
if(rateDirection < 0)
{
while(m_bMouseIsDown && m_CurrentValue > Value->dblVal - maxRateChange)
{
m_CurrentValue-= maxRateChange;
m_lpControlKnob->SetValue(m_CurrentValue);
CHECK_FOR_PARENT_MESSAGES(m_ParentWnd);
dwDelayed = GetTickCount() - dwStart;
if(dwDelayed < LOOP_DELAY_MS)
{
Sleep(LOOP_DELAY_MS - dwDelayed);
}
dwStart = GetTickCount();
}
}
else
{
while(m_bMouseIsDown && m_CurrentValue< Value->dblVal + maxRateChange)
{
m_CurrentValue+= maxRateChange;
m_lpControlKnob->SetValue(m_CurrentValue);
CHECK_FOR_PARENT_MESSAGES(m_ParentWnd);
dwDelayed = GetTickCount() - dwStart;
if(dwDelayed < LOOP_DELAY_MS)
{
Sleep(LOOP_DELAY_MS - dwDelayed);
}
dwStart = GetTickCount();
}
}
if(m_bMouseIsDown)
{
m_CurrentValue= lastVal = Value->dblVal;
}
m_lpControlKnob->SetValue(m_CurrentValue);
}