在CStageButton類的實(shí)現(xiàn)代碼中,設(shè)置當(dāng)鼠標(biāo)按下時(shí)觸發(fā)的云臺(tái)控制代碼和鼠標(biāo)抬起時(shí)停止對(duì)云臺(tái)的控制。代碼如下:
//當(dāng)按下鼠標(biāo)按鈕時(shí),根據(jù)按鈕的類型標(biāo)識(shí)調(diào)用不同的方法
void CStageButton::OnLButtonDown(UINT nFlags, CPoint point)
{
switch(m_Type)
{
case ctUp:
{
((CCaptureDlg*)GetParent())->OnUp(); //控制云臺(tái)向上
break;
}
case ctDown:
{
((CCaptureDlg*)GetParent())->OnDown(); //控制云臺(tái)向下
break;
}
case ctLeft:
{
((CCaptureDlg*)GetParent())->OnLeft(); //控制云臺(tái)向左
break;
}
case ctRight:
{
((CCaptureDlg*)GetParent())->OnRight(); //控制云臺(tái)向右
break;
}
case ctInFoci:
{
((CCaptureDlg*)GetParent())->OnInFoci(); //設(shè)置聚焦減
break;
}
case ctReFoci:
{
((CCaptureDlg*)GetParent())->OnReFoci(); //設(shè)置聚焦增
break;
}
case ctInLen:
{
((CCaptureDlg*)GetParent())->OnInLen(); //設(shè)置對(duì)焦減
break;
}
case ctReLen:
{
((CCaptureDlg*)GetParent())->OnReLen(); //設(shè)置對(duì)焦增
break;
}
case ctInAperture:
{
((CCaptureDlg*)GetParent())->OnInAperture(); //設(shè)置光圈減
break;
}
case ctReAperture:
{
((CCaptureDlg*)GetParent())->OnReAperture(); //設(shè)置光圈增
break;
}
case ctInBrush:
{
((CCaptureDlg*)GetParent())->OnInBrush(); //設(shè)置畫筆減
break;
}
case ctReBrush:
{
((CCaptureDlg*)GetParent())->OnReBrush(); //設(shè)置畫筆增
break;
}
default:
{
break;
}
}
CButton::OnLButtonDown(nFlags, point);
}
//當(dāng)釋放鼠標(biāo)按鈕時(shí)停止對(duì)云臺(tái)的控制
void CStageButton::OnLButtonUp(UINT nFlags, CPoint point)
{
((CCaptureDlg*)GetParent())->OnReset();
CButton::OnLButtonUp(nFlags, point);
}