?? realdlg.cpp
字號:
// RealDlg.cpp : implementation file
//
#include "stdafx.h"
#include "JHHB.h"
#include "RealDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CRealDlg dialog
CRealDlg::CRealDlg(int nSeleStation,CCommInfo * pComm,CWnd * pParent /*=NULL*/)
: CDialog(CRealDlg::IDD, pParent)
{
ASSERT(pComm!=NULL);
m_nSeleStation= nSeleStation;
m_pComm = pComm;
m_lTotalSeconds=0;
m_lTotalTimes=0;
//{{AFX_DATA_INIT(CRealDlg)
//}}AFX_DATA_INIT
}
void CRealDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CRealDlg)
DDX_Control(pDX, IDC_WAIT_PRO, m_proWait);
DDX_Control(pDX, IDSTOP, m_buttonStop);
DDX_Control(pDX, IDSTART, m_buttonStart);
DDX_Control(pDX, IDOK, m_buttonOK);
DDX_Control(pDX, IDC_RELAYSHOW, m_RelayShow);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CRealDlg, CDialog)
//{{AFX_MSG_MAP(CRealDlg)
ON_BN_CLICKED(IDSTART, OnStart)
ON_BN_CLICKED(IDSTOP, OnStop)
ON_BN_CLICKED(IDC_RELAYSHOW, OnRelayshow)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRealDlg message handlers
BOOL CRealDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_proWait.SetRange(nProgCtrl_MIN,nProgCtrl_MAX );
m_proWait.SetStep(nProgCtrl_STEP);
m_nProgCtrlCurrentPos=nProgCtrl_MIN;
m_proWait.SetPos(m_nProgCtrlCurrentPos);
CString strRelayTitleFmt;
GetDlgItemText(IDC_RELAY_TITLE, strRelayTitleFmt);
CString strRelayTitle;
if (m_nSeleStation<=6)
strRelayTitle.Format(strRelayTitleFmt,m_nSeleStation);
else
strRelayTitle.Format(strRelayTitleFmt,m_nSeleStation+2);
SetDlgItemText(IDC_RELAY_TITLE, strRelayTitle );
GetDlgItem(IDC_RELAY_TITLE)->EnableWindow(FALSE);
CString strRelayFoot;
strRelayFoot.Format(IDS_RELAY_FOOT,m_lTotalSeconds,m_lTotalTimes);
SetDlgItemText(IDC_RELAY_FOOT,strRelayFoot);
m_buttonStart.EnableWindow(TRUE);
m_buttonStop.EnableWindow(TRUE);
m_buttonOK.EnableWindow(TRUE);
m_RelayShow.m_bNeedRedraw=FALSE;
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CRealDlg::OnStart()
{
SendStartString(m_nSeleStation);
m_lTotalSeconds=0;
m_lTotalTimes=0;
CString strRelayFoot;
strRelayFoot.Format(IDS_RELAY_FOOT,m_lTotalSeconds,m_lTotalTimes);
SetDlgItemText(IDC_RELAY_FOOT,strRelayFoot);
m_buttonStart.EnableWindow(FALSE);
m_buttonOK.EnableWindow(FALSE);
m_RelayShow.m_status = CRelayShow::RELAY_STATUS_WAITFRIST;
m_RelayShow.Invalidate(); //Redraw the client area
}
void CRealDlg::RefreshRelay(BYTE * pDataBuff)
{
ASSERT(pDataBuff!=NULL);
ASSERT(*(BYTE *)(pDataBuff+4)==m_nSeleStation);
if (m_RelayShow.m_status!= CRelayShow::RELAY_STATUS_STOP)
{
m_lTotalSeconds+=10;
m_lTotalTimes+=1;
CString strRelayFoot;
strRelayFoot.Format(IDS_RELAY_FOOT,m_lTotalSeconds,m_lTotalTimes);
SetDlgItemText(IDC_RELAY_FOOT,strRelayFoot);
m_RelayShow.m_bNeedRedraw=TRUE;
m_RelayShow.UpdateDisplayBuff(pDataBuff);
m_RelayShow.m_status = CRelayShow::RELAY_STATUS_STRANSDATA;
m_RelayShow.Invalidate(); //Redraw the client area
}
}
void CRealDlg::SendStartString(int nStation)
{
ASSERT(m_pComm != NULL);
if (!m_pComm->m_bConnected)
if (m_pComm->OpenConnection() == FALSE)
ASSERT(FALSE);
m_strSend = _T("");
m_strSend += (TCHAR)nStation;
CString strStart;
strStart.LoadString(IDS_COMMSTARTTOKEN);
m_strSend += strStart;
/* CString strInfo;
strInfo.Format(IDS_LOGSENDSTART,nStation);
GetLogView()->AddNewLog(strInfo);
*/
m_pComm->WriteCommBlock(m_strSend,m_strSend.GetLength());
}
void CRealDlg::OnStop()
{
SendStopString(m_nSeleStation);
m_RelayShow.m_status = CRelayShow::RELAY_STATUS_STOP;
m_RelayShow.Invalidate(); //Redraw the client area
m_buttonStart.EnableWindow(TRUE);
m_buttonOK.EnableWindow(TRUE);
}
void CRealDlg::SendStopString(int nStation)
{
ASSERT(m_pComm != NULL);
if (!m_pComm->m_bConnected)
if (m_pComm->OpenConnection() == FALSE)
ASSERT(FALSE);
m_strSend = _T("");
// m_strSend += (TCHAR)nStation;
CString strStop;
strStop.LoadString(IDS_COMMSTOPTOKEN);
m_strSend += strStop;
/* CString strInfo;
strInfo.Format(IDS_LOGSENDSTART,nStation);
GetLogView()->AddNewLog(strInfo);
*/
m_pComm->WriteCommBlock(m_strSend,m_strSend.GetLength());
}
void CRealDlg::UpdateWaitProgressCtrl()
{
if (m_RelayShow.m_status == CRelayShow::RELAY_STATUS_WAITFRIST||
m_RelayShow.m_status == CRelayShow::RELAY_STATUS_STRANSDATA)
{
if (m_nProgCtrlCurrentPos==nProgCtrl_MAX)
m_nProgCtrlCurrentPos=nProgCtrl_MIN;
else
m_nProgCtrlCurrentPos++;
m_proWait.SetPos(m_nProgCtrlCurrentPos);
}
}
void CRealDlg::OnRelayshow()
{
// TODO: Add your control notification handler code here
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -