?? monicontroldlg.cpp
字號:
if(m_CRect_N.PtInRect(myPoint))
{
m_Near.SetIcon(hIconN_P);
SendCommand(20400);
MSG myMsg;
this->SetCapture();
while(1)
{
if(GetMessage(&myMsg,NULL,WM_LBUTTONUP,WM_LBUTTONUP))
{
Sleep(20);
m_Near.SetIcon(hIconN_O);
SendCommand(20401);
Sleep(20);
::ReleaseCapture();
break;
}
}
}
//按下【長】按鈕
if(m_CRect_LG.PtInRect(myPoint))
{
m_Long.SetIcon(hIconLG_P);
SendCommand(20500);
MSG myMsg;
this->SetCapture();
while(1)
{
if(GetMessage(&myMsg,NULL,WM_LBUTTONUP,WM_LBUTTONUP))
{
Sleep(20);
m_Long.SetIcon(hIconLG_O);
SendCommand(20501);
Sleep(20);
::ReleaseCapture();
break;
}
}
}
//按下【短】按鈕
if(m_CRect_SH.PtInRect(myPoint))
{
m_Short.SetIcon(hIconSH_P);
SendCommand(20600);
MSG myMsg;
this->SetCapture();
while(1)
{
if(GetMessage(&myMsg,NULL,WM_LBUTTONUP,WM_LBUTTONUP))
{
Sleep(20);
m_Short.SetIcon(hIconSH_O);
SendCommand(20601);
Sleep(20);
::ReleaseCapture();
break;
}
}
}
//按下【大】微調(diào)按鈕
if(m_CRect_BM.PtInRect(myPoint))
{
m_BigMicro.SetIcon(hIconB_P);
SendCommand(20110);
MSG myMsg;
this->SetCapture();
while(1)
{
if(GetMessage(&myMsg,NULL,WM_LBUTTONUP,WM_LBUTTONUP))
{
Sleep(20);
m_BigMicro.SetIcon(hIconB_O);
m_ActStatus.SetWindowText("無操作!");
//SendCommand(20111);
//Sleep(20);
::ReleaseCapture();
break;
}
}
}
//按下【小】微調(diào)按鈕
if(m_CRect_SM.PtInRect(myPoint))
{
m_SmallMicro.SetIcon(hIconS_P);
SendCommand(20210);
MSG myMsg;
this->SetCapture();
while(1)
{
if(GetMessage(&myMsg,NULL,WM_LBUTTONUP,WM_LBUTTONUP))
{
Sleep(20);
m_SmallMicro.SetIcon(hIconS_O);
m_ActStatus.SetWindowText("無操作!");
//SendCommand(20211);
//Sleep(20);
::ReleaseCapture();
break;
}
}
}
//按下【遠(yuǎn)】微調(diào)按鈕
if(m_CRect_FM.PtInRect(myPoint))
{
m_FarMicro.SetIcon(hIconF_P);
SendCommand(20310);
MSG myMsg;
this->SetCapture();
while(1)
{
if(GetMessage(&myMsg,NULL,WM_LBUTTONUP,WM_LBUTTONUP))
{
Sleep(20);
m_FarMicro.SetIcon(hIconF_O);
m_ActStatus.SetWindowText("無操作!");
//SendCommand(20311);
//Sleep(20);
::ReleaseCapture();
break;
}
}
}
//按下【近】微調(diào)按鈕
if(m_CRect_NM.PtInRect(myPoint))
{
m_NearMicro.SetIcon(hIconN_P);
SendCommand(20410);
MSG myMsg;
this->SetCapture();
while(1)
{
if(GetMessage(&myMsg,NULL,WM_LBUTTONUP,WM_LBUTTONUP))
{
Sleep(20);
m_NearMicro.SetIcon(hIconN_O);
m_ActStatus.SetWindowText("無操作!");
//SendCommand(20411);
//Sleep(20);
::ReleaseCapture();
break;
}
}
}
//按下【長】微調(diào)按鈕
if(m_CRect_LGM.PtInRect(myPoint))
{
m_LongMicro.SetIcon(hIconLG_P);
SendCommand(20510);
MSG myMsg;
this->SetCapture();
while(1)
{
if(GetMessage(&myMsg,NULL,WM_LBUTTONUP,WM_LBUTTONUP))
{
Sleep(20);
m_LongMicro.SetIcon(hIconLG_O);
m_ActStatus.SetWindowText("無操作!");
//SendCommand(20511);
//Sleep(20);
::ReleaseCapture();
break;
}
}
}
//按下【短】微調(diào)按鈕
if(m_CRect_SHM.PtInRect(myPoint))
{
m_ShortMicro.SetIcon(hIconSH_P);
SendCommand(20610);
MSG myMsg;
this->SetCapture();
while(1)
{
if(GetMessage(&myMsg,NULL,WM_LBUTTONUP,WM_LBUTTONUP))
{
Sleep(20);
m_ShortMicro.SetIcon(hIconSH_O);
m_ActStatus.SetWindowText("無操作!");
//SendCommand(20611);
//Sleep(20);
::ReleaseCapture();
break;
}
}
}
//按下【開】雨刷按鈕
if(m_CRect_OB.PtInRect(myPoint))
{
m_OpenBrush.SetIcon(hIconO_P);
SendCommand(30100);
MSG myMsg;
this->SetCapture();
while(1)
{
if(GetMessage(&myMsg,NULL,WM_LBUTTONUP,WM_LBUTTONUP))
{
Sleep(20);
m_OpenBrush.SetIcon(hIconO_O);
m_ActStatus.SetWindowText("無操作!");
//SendCommand(30101);
//Sleep(20);
::ReleaseCapture();
break;
}
}
}
//按下【關(guān)】雨刷按鈕
if(m_CRect_CB.PtInRect(myPoint))
{
m_CloseBrush.SetIcon(hIconC_P);
SendCommand(30200);
MSG myMsg;
this->SetCapture();
while(1)
{
if(GetMessage(&myMsg,NULL,WM_LBUTTONUP,WM_LBUTTONUP))
{
Sleep(20);
m_CloseBrush.SetIcon(hIconC_O);
m_ActStatus.SetWindowText("無操作!");
//SendCommand(30201);
//Sleep(20);
::ReleaseCapture();
break;
}
}
}
//按下【開】射燈按鈕
if(m_CRect_OL.PtInRect(myPoint))
{
m_OpenLight.SetIcon(hIconO_P);
SendCommand(30300);
MSG myMsg;
this->SetCapture();
while(1)
{
if(GetMessage(&myMsg,NULL,WM_LBUTTONUP,WM_LBUTTONUP))
{
Sleep(20);
m_OpenLight.SetIcon(hIconO_O);
m_ActStatus.SetWindowText("無操作!");
//SendCommand(30301);
//Sleep(20);
::ReleaseCapture();
break;
}
}
}
//按下【關(guān)】射燈按鈕
if(m_CRect_CL.PtInRect(myPoint))
{
m_CloseLight.SetIcon(hIconC_P);
SendCommand(30400);
MSG myMsg;
this->SetCapture();
while(1)
{
if(GetMessage(&myMsg,NULL,WM_LBUTTONUP,WM_LBUTTONUP))
{
Sleep(20);
m_CloseLight.SetIcon(hIconC_O);
m_ActStatus.SetWindowText("無操作!");
//SendCommand(30401);
//Sleep(20);
::ReleaseCapture();
break;
}
}
}
CDialog::OnLButtonDown(nFlags, point);
}
void CMoniControlDlg::OnOpencom()
{
// TODO: Add your control notification handler code here
CComboBox *m_ComboCom=NULL;
CComboBox *m_ComboBaudRate=NULL;
UpdateData(true); //更新控件的數(shù)據(jù)
//計(jì)算串口通信參數(shù)
CString strPara; //串口參數(shù)字符串
myComm.SetCommPort(m_Com+1); //指定串口號
switch(m_BaudRate)
{
case 0:
{
strPara="9600";
break;
}
case 1:
{
strPara="4800";
break;
}
case 2:
{
strPara="2400";
break;
}
case 3:
{
strPara="1200";
break;
}
}
strPara+=",N,8,1";
myComm.SetSettings(strPara); //通信參數(shù)設(shè)置
myComm.SetInBufferSize(1024); //指定接收緩沖區(qū)大小
myComm.SetInBufferCount(0); //清空接收緩沖區(qū)
myComm.SetInputMode(1); //設(shè)置數(shù)據(jù)獲取方式
myComm.SetInputLen(0); //設(shè)置每次讀取長度
myComm.SetRThreshold(1); //設(shè)置接收OnComm事件門限值
myComm.SetPortOpen(1); //打開串口
m_OpenCom.EnableWindow(false); //使打開串口按鈕無效
m_CloseCom.EnableWindow(true); //使關(guān)閉串口按鈕生效
AfxMessageBox("串口打開成功!");
m_ComboCom=(CComboBox*)GetDlgItem(IDC_COMBO_COM);
m_ComboCom->EnableWindow(false); //使端口選擇框無效
m_ComboBaudRate=(CComboBox*)GetDlgItem(IDC_COMBO_BAUDRATE);
m_ComboBaudRate->EnableWindow(false); //使波特率選擇框無效
}
void CMoniControlDlg::OnClosecom()
{
// TODO: Add your control notification handler code here
CComboBox *m_ComboCom=NULL;
CComboBox *m_ComboBaudRate=NULL;
m_OpenCom.EnableWindow(true); //使打開串口按鈕生效
m_CloseCom.EnableWindow(false); //使關(guān)閉串口按鈕無效
myComm.SetPortOpen(0);
AfxMessageBox("串口關(guān)閉成功!");
m_ComboCom=(CComboBox*)GetDlgItem(IDC_COMBO_COM);
m_ComboCom->EnableWindow(true); //使端口選擇框生效
m_ComboBaudRate=(CComboBox*)GetDlgItem(IDC_COMBO_BAUDRATE);
m_ComboBaudRate->EnableWindow(true); //使波特率選擇框生效
}
void CMoniControlDlg::OnCloseupComboAddress()
{
// TODO: Add your control notification handler code here
UpdateData(true);
SendCommand(40100); //發(fā)送切換設(shè)備地址命令
Sleep(20);
}
//************************************
//*******獲取靜態(tài)按鈕的位置數(shù)據(jù)*******
//************************************
CRect CMoniControlDlg::GetRect(CStatic *pStatic)
{
RECT myRect;
CRect myCRect;
pStatic->GetWindowRect(&myRect);
myCRect.top=myRect.top;
myCRect.left=myRect.left;
myCRect.right=myRect.right;
myCRect.bottom=myRect.bottom;
return myCRect;
}
void CMoniControlDlg::OnMove(int x, int y)
{
CDialog::OnMove(x, y);
// TODO: Add your message handler code here
bMoved=true; //置位主窗口移動(dòng)過標(biāo)志
}
void CMoniControlDlg::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
POINT myPoint;
myPoint.x=point.x;
myPoint.y=point.y;
//轉(zhuǎn)換客戶區(qū)坐標(biāo)值到屏幕區(qū)
ClientToScreen(&myPoint);
//若主對話框移動(dòng)過,重新計(jì)算各按鈕的位置
if(bMoved)
{
bMoved=false; //復(fù)位移動(dòng)標(biāo)志
m_CRect_U=GetRect(&m_Up); //獲取上按鈕位置
m_CRect_D=GetRect(&m_Down);
m_CRect_L=GetRect(&m_Left);
m_CRect_R=GetRect(&m_Right);
m_CRect_UM=GetRect(&m_UpMicro);
m_CRect_DM=GetRect(&m_DownMicro);
m_CRect_LM=GetRect(&m_LeftMicro);
m_CRect_RM=GetRect(&m_RightMicro);
m_CRect_LU=GetRect(&m_LeftUp);
m_CRect_LD=GetRect(&m_LeftDown);
m_CRect_RU=GetRect(&m_RightUp);
m_CRect_RD=GetRect(&m_RightDown);
m_CRect_B=GetRect(&m_Big);
m_CRect_BM=GetRect(&m_BigMicro);
m_CRect_S=GetRect(&m_Small);
m_CRect_SM=GetRect(&m_SmallMicro);
m_CRect_F=GetRect(&m_Far);
m_CRect_FM=GetRect(&m_FarMicro);
m_CRect_N=GetRect(&m_Near);
m_CRect_NM=GetRect(&m_NearMicro);
m_CRect_LG=GetRect(&m_Long);
m_CRect_LGM=GetRect(&m_LongMicro);
m_CRect_SH=GetRect(&m_Short);
m_CRect_SHM=GetRect(&m_ShortMicro);
m_CRect_OB=GetRect(&m_OpenBrush);
m_CRect_CB=GetRect(&m_CloseBrush);
m_CRect_OL=GetRect(&m_OpenLight);
m_CRect_CL=GetRect(&m_CloseLight);
}
//鼠標(biāo)進(jìn)入【上】按鈕或離開【上】按鈕
if(m_CRect_U.PtInRect(myPoint))
{
m_Up.SetIcon(hIconU_O);
}
else
{
m_Up.SetIcon(hIconU_N);
}
//【下】
if(m_CRect_D.PtInRect(myPoint))
{
m_Down.SetIcon(hIconD_O);
}
else
{
m_Down.SetIcon(hIconD_N);
}
//【左】
if(m_CRect_L.PtInRect(myPoint))
{
m_Left.SetIcon(hIconL_O);
}
else
{
m_Left.SetIcon(hIconL_N);
}
//【右】
if(m_CRect_R.PtInRect(myPoint))
{
m_Right.SetIcon(hIconR_O);
}
else
{
m_Right.SetIcon(hIconR_N);
}
//【左上】
if(m_CRect_LU.PtInRect(myPoint))
{
m_LeftUp.SetIcon(hIconLU_O);
}
else
{
m_LeftUp.SetIcon(hIconLU_N);
}
//【左下】
if(m_CRect_LD.PtInRect(myPoint))
{
m_LeftDown.SetIcon(hIconLD_O);
}
else
{
m_LeftDown.SetIcon(hIconLD_N);
}
//【右上】
if(m_CRect_RU.PtInRect(myPoint))
{
m_RightUp.SetIcon(hIconRU_O);
}
else
{
m_RightUp.SetIcon(hIconRU_N);
}
//【右下】
if(m_CRect_RD.PtInRect(myPoint))
{
m_RightDown.SetIcon(hIconRD_O);
}
else
{
m_RightDown.SetIcon(hIconRD_N);
}
//【上】,微調(diào)
if(m_CRect_UM.PtInRect(myPoint))
{
m_UpMicro.SetIcon(hIconU_O);
}
else
{
m_UpMicro.SetIcon(hIconU_N);
}
//【下】,微調(diào)
if(m_CRect_DM.PtInRect(myPoint))
{
m_DownMicro.SetIcon(hIconD_O);
}
else
{
m_DownMicro.SetIcon(hIconD_N);
}
//【左】,微調(diào)
if(m_CRect_LM.PtInRect(myPoint))
{
m_LeftMicro.SetIcon(hIconL_O);
}
else
{
m_LeftMicro.SetIcon(hIconL_N);
}
//【右】,微調(diào)
if(m_CRect_RM.PtInRect(myPoint))
{
m_RightMicro.SetIcon(hIconR_O);
}
else
{
m_RightMicro.SetIcon(hIconR_N);
}
//【大】光圈
if(m_CRect_B.PtInRect(myPoint))
{
m_Big.SetIcon(hIconB_O);
}
else
{
m_Big.SetIcon(hIconB_N);
}
//【小】光圈
if(m_CRect_S.PtInRect(myPoint))
{
m_Small.SetIcon(hIconS_O);
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -