在CameraController程序中,
一、按钮消息响应机制:
云台控制和镜头控制的所有消息响应,都经过PreTranslateMessage(MSG* pMsg)进行消息截获:
以前见过这个函数的使用:
BOOL CYTCONTROLDlg::PreTranslateMessage(MSG* pMsg) //可以实现鼠标按下执行上下左右命令,释放鼠标执行停的效果
{
// TODO: Add your specialized code here and/or call the base class
if (pMsg->message==WM_LBUTTONDOWN)
{
if ( pMsg->hwnd == GetDlgItem(IDC_BUTTON_LEFT)->m_hWnd )
OnButtonLeft();
if ( pMsg->hwnd == GetDlgItem(IDC_BUTTON_RIGHT)->m_hWnd )
OnButtonRight();
if ( pMsg->hwnd == GetDlgItem(IDC_BUTTON_UP)->m_hWnd )
OnButtonUp();
if ( pMsg->hwnd == GetDlgItem(IDC_BUTTON_DOWN)->m_hWnd )
OnButtonDown();
}
return CDialog::PreTranslateMessage(pMsg);
}
在CameraController程序中:
BOOL CCameraControllerDlg::PreTranslateMessage(MSG* pMsg)
{
this->m_tt.RelayEvent(pMsg);
if(this->m_bOpend) { //串口被打开后
CWnd * pWnd = CWnd::FromHandle(pMsg->hwnd);
UINT msgId = pMsg->message;
INT nId = 0;
BYTE b[8];
b[0] = 0;
if(m