在CStageButton类的实现代码中,设置当鼠标按下时触发的云台控制代码和鼠标抬起时停止对云台的控制。代码如下:
//当按下鼠标按钮时,根据按钮的类型标识调用不同的方法
void CStageButton::OnLButtonDown(UINT nFlags, CPoint point)
{
switch(m_Type)
{
case ctUp:
{
((CCaptureDlg*)GetParent())->OnUp(); //控制云台向上
break;
}
case ctDown:
{
((CCaptureDlg*)GetParent())->OnDown(); //控制云台向下
break;
}
case ctLeft:
{
((CCaptureDlg*)GetParent())->OnLeft(); //控制云台向左
break;
}
case ctRight:
{
((CCaptureDlg*)GetParent())->OnRight(); //控制云台向右
break;
}
case ctInFoci:
{
((CCaptureDlg*)GetParent())->OnInFoci(); //设置聚焦减
break;
}
case ctReFoci:
{
((CCaptureDlg*)GetParent())->OnReFoci(); //设置聚焦增
break;
}
case ctInLen:
{
((CCaptureDlg*)GetParent())->OnInLen(); //设置对焦减
break;
}
case ctReLen:
{
((CCaptureDlg*)GetParent())->OnReLen(); //设置对焦增
break;
}
case ctInAperture:
{
((CCaptureDlg*)GetParent())->OnInAperture(); //设置光圈减
break;
}
case ctReAperture:
{
((CCaptureDlg*)GetParent())->OnReAperture(); //设置光圈增
break;
}
case ctInBrush:
{
((CCaptureDlg*)GetParent())->OnInBrush(); //设置画笔减
break;
}
case ctReBrush:
{
((CCaptureDlg*)GetParent())->OnReBrush(); //设置画笔增
break;
}
default:
{
break;
}
}
CButton::OnLButtonDown(nFlags, point);
}
//当释放鼠标按钮时停止对云台的控制
void CStageButton::OnLButtonUp(UINT nFlags, CPoint point)
{
((CCaptureDlg*)GetParent())->OnReset();
CButton::OnLButtonUp(nFlags, point);
}