void CRobotClientDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
CSliderCtrl *Slide = dynamic_cast<CSliderCtrl *>(pScrollBar);
CString CmdStr;
if (!Slide)
{
//MessageBox("Slider didn''t cast");
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
return;
}
if (nSBCode != TB_THUMBTRACK)
{
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
return;
}
int i = Slide->GetDlgCtrlID() - 1100;
if (i >= 0 && i <= 7) // it''s a PWM control
{
UpdateData();
m_PWM_Edit[i] = (float)m_PWM[i].GetPos() / (float)10;
// PWM1 needs to be made to agree with PWM0
if (i == 0 && m_Lash)
{
m_PWM_Edit[1] = m_PWM_Edit[0];
m_PWM[1].SetPos(m_PWM[0].GetPos());
}
UpdateData(FALSE);
SendPWMValue(i);
}
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}
bool CRobotClientDlg::SendPWMValue(int PWM, bool Force)
{
CString CmdStr;
// don''t send anything if the timeout hasn''t expired, the send isn''t forced, and the send isn''t a stop command
if (!ReadyToSendPWM && !Force && m_PWM_Edit[PWM] != 0)
return true;
if (theApp.Socket)
{
ReadyToSendPWM = false;
CmdStr.Format("Ctrl.PWM%d:%.1f\r\n", PWM, m_PWM_Edit[PWM]);
if (!theApp.Socket->Send(&CmdStr))
return false;
// TODO send if lashed
}
else
return false;
return true;
}
--------------------You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming
You are unique. Just like everybody else.
"Mechanical engineers design weapons; civil engineers design targets."
"Sensitivity is adjustable, so you can set it to detect elephants and other small creatures." -- Product Description for a vibration sensor