📄 ctpstatusdlg.cpp
字号:
// CCTPStatusDlg - class, which implements dialog for keeping eye on CTP
// status
// Implementation file
//
// (c) Lev Naumov, CAMEL Laboratory
// E-mail: camellab@mail.ru
// For more information see http://camel.ifmo.ru or
// http://www.codeproject.com/internet/ctp.asp
/////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "CTPDemo.h"
#include "NetBasic.h"
#include "CTPNet.h"
#include "CTPStatusDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCTPStatusDlg dialog
CCTPStatusDlg::CCTPStatusDlg(CCTPNet& ctp, UINT cycle, CWnd* pParent /*=NULL*/)
:m_CTP(ctp),CDialog(CCTPStatusDlg::IDD,pParent)
{
m_uCycle=cycle;
m_uTimer=0;
//{{AFX_DATA_INIT(CCTPStatusDlg)
//}}AFX_DATA_INIT
}
void CCTPStatusDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCTPStatusDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCTPStatusDlg, CDialog)
//{{AFX_MSG_MAP(CCTPStatusDlg)
ON_WM_TIMER()
ON_WM_SHOWWINDOW()
ON_BN_CLICKED(IDC_BSUSPEND, OnBsuspend)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCTPStatusDlg message handlers
BOOL CCTPStatusDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Make window an "always on top" one
CRect rect;
GetWindowRect(rect);
SetWindowPos(&wndTopMost,rect.left,rect.top,rect.right,rect.bottom,SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE);
// Set the timer of refreshment
m_uTimer=SetTimer(1,m_uCycle,NULL);
// Set suspended status
SetSuspendStatus();
return TRUE;
}
void CCTPStatusDlg::SetSuspendStatus()
{
CString s;
if (m_CTP.GetSuspended()) {
CheckDlgButton(IDC_BSUSPEND,1);
s.LoadString(IDS_CTP_RESUME);
} else {
CheckDlgButton(IDC_BSUSPEND,0);
s.LoadString(IDS_CTP_SUSPEND);
}
GetDlgItem(IDC_BSUSPEND)->SetWindowText(s);
}
void CCTPStatusDlg::OnTimer(UINT nIDEvent)
{
// Update status info
CString s;
s.Format("%u",m_CTP.GetSessionsCount());
GetDlgItem(IDC_ESESSIONS)->SetWindowText(s);
s.Format("%u",m_CTP.GetSntCommandsCount());
GetDlgItem(IDC_ESNTCOMM)->SetWindowText(s);
s.Format("%u",m_CTP.GetLrgMessagesCount());
GetDlgItem(IDC_ELRGMESS)->SetWindowText(s);
s.Format("%u",m_CTP.GetDelCount());
GetDlgItem(IDC_EDELIVERIES)->SetWindowText(s);
s.Format("%u",m_CTP.GetDelThreadsCount());
GetDlgItem(IDC_EDTTOTAL)->SetWindowText(s);
s.Format("%u",m_CTP.GetBusyDelThreadsCount());
GetDlgItem(IDC_EDTBUSY)->SetWindowText(s);
SetSuspendStatus();
CDialog::OnTimer(nIDEvent);
}
BOOL CCTPStatusDlg::DestroyWindow()
{
if (m_uTimer) KillTimer(m_uTimer);
return CDialog::DestroyWindow();
}
void CCTPStatusDlg::OnShowWindow(BOOL bShow, UINT nStatus)
{
CDialog::OnShowWindow(bShow, nStatus);
if (bShow) {
if (!m_uTimer) m_uTimer=SetTimer(1,m_uCycle,NULL);
} else {
KillTimer(m_uTimer);
m_uTimer=0;
}
}
void CCTPStatusDlg::OnBsuspend()
{
if (IsDlgButtonChecked(IDC_BSUSPEND)) m_CTP.SetSuspended(true); else m_CTP.SetSuspended(false);
SetSuspendStatus();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -