BOOL Cxx::PreTranslateMessage(MSG* pMsg) { // TODO: 在此添加專用代碼和/或調用基類 CString strShow = _T(""); if(pMsg->message == WM_LBUTTONDOWN)//按鈕按下 { //按鈕按下 if(pMsg->hwnd == GetDlgItem(IDC_BTNRIGHT)->m_hWnd) { // 在此調用Button按鈕按下的操作 //發送控制設備右移指令 SendCmdtoComm(m_cmdmoveright); SetDlgItemText(IDC_EDIT10,_T("設備右移指令已發送!")); pMsg->hwnd =NULL;//注意:如未添加該句,則會出錯 } } else if(pMsg->message == WM_LBUTTONUP)//按鈕松開 { //按鈕松開 if(pMsg->hwnd == GetDlgItem(IDC_BTNRIGHT)->m_hWnd) { // 在此調用Button按鈕抬起的操作 //發送設備停止右移指令 SendCmdtoComm(m_cmdmovestop); SetDlgItemText(IDC_EDIT10,_T("設備右移結束!")); pMsg->hwnd =NULL; } } return CDialog::PreTranslateMessage(pMsg); }
---------------------
作者:startfromnow86
來源:CSDN
原文:https://blog.csdn.net/sihua3211/article/details/79136231
版權聲明:本文為博主原創文章,轉載請附上博文鏈接!