I want to determine the rate (frequency) at which a slider can be moved in a MFC based Visual C++ program (using Visual Studio 2012). So how do I get the appropriate polling rate programmatically?
Here is the code I use for capturing the slider value:
void CMainDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
// catches slider horizontal scrolling events
{
double val;
ScopeGuardMutex guard(&m_mutex);
val = (double)(((CSliderCtrl *)pScrollBar)->GetPos()) / (double)SLD_MAX;
rec->param = val;
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}
If this value cannot be determined programmatically then is there an approximate value e.g. 100Hz?
I have realised that I was not approaching this problem in the right way. The rate at which the slider value is changed is not important, rather what is important is the rate at which the slider value is followed. The two rates are independent. Assuming the parameter being controlled by the slider is in the range 0 to 1, the rate at which the slider value is followed (r) and the maximum frequency (f) at which the value is allowed to change are what should be used in a slew rate limiter to calculate the maximum step size (s), as follows:
s = 2 * f / r
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments