📄 secretcomm.cpp
字号:
// SecretComm.cpp : implementation file
//
#include "stdafx.h"
#include "rectvinfo.h"
#include "SecretComm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSecretComm dialog
CRectvinfoApp* theSecretDlgApp;
CSecretComm::CSecretComm(CWnd* pParent /*=NULL*/)
: CDialog(CSecretComm::IDD, pParent)
{
//{{AFX_DATA_INIT(CSecretComm)
m_md = 1;
m_statictxt = _T("月份:");
//}}AFX_DATA_INIT
}
void CSecretComm::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSecretComm)
DDX_Control(pDX, IDC_COMBO_TERMID, m_termid);
DDX_Control(pDX, IDC_COMBO_DATATYPE, m_datatype);
DDX_Text(pDX, IDC_EDIT_MD, m_md);
DDV_MinMaxByte(pDX, m_md, 1, 31);
DDX_Text(pDX, IDC_STATIC_MD, m_statictxt);
DDV_MaxChars(pDX, m_statictxt, 20);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSecretComm, CDialog)
//{{AFX_MSG_MAP(CSecretComm)
ON_CBN_SELCHANGE(IDC_COMBO_DATATYPE, OnSelchangeComboDatatype)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSecretComm message handlers
void CSecretComm::OnOK()
{
// TODO: Add extra validation here
unsigned int order,j,i;
SYSTEMTIME loctime;
DWORD twoparam;
UpdateData(TRUE);
if (m_termid.GetCount()==0) MessageBox("目前没有联机的终端!");
else
{
order = m_datatype.GetCurSel();
if (order==0)
{
if ((m_md<1)||(m_md>12))
{
MessageBox("月份错误!");
return;
}
}
else
{
GetLocalTime(&loctime);
if (order==2) //上月
{
if (loctime.wMonth==1) loctime.wMonth=12;
else loctime.wMonth-=1;
}
if (loctime.wMonth==2)
{
if (loctime.wYear%4==0) j = 29;
else j = 28;
}
else if ((loctime.wMonth==4)||(loctime.wMonth==6)||(loctime.wMonth==9)||(loctime.wMonth==10)||(loctime.wMonth==12))
{
j = 30;
}
else j = 31;
if ((m_md<1)||(m_md>j))
{
MessageBox("日期错误!");
return;
}
}
order+=0x23;
j = (m_md/10)*16+m_md%10;
twoparam = order | (j<<16);
i = m_termid.GetCurSel();
i = route[i];
// i=0;
if ((i>=MAXCLIENTNUM)||(i<0)) MessageBox("严重错误!");
else
{
theSecretDlgApp->CommPtr->PostThreadMessage(UPLOADDATA, WPARAM(twoparam), LPARAM(i));
}
}
CDialog::OnOK();
}
BOOL CSecretComm::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
theSecretDlgApp = (CRectvinfoApp*)AfxGetApp();
int i,ti=0;
char * telnum;
SOCKET ts;
for (i=0;i<MAXCLIENTNUM;i++)
{
telnum = theSecretDlgApp->GetSocketTel(i);
ts = theSecretDlgApp->GetSocket(i);
if((strlen(telnum)==4)&&(ts!=NULL))
{
m_termid.InsertString(ti,(LPCTSTR)telnum);
route[ti] = i;
ti++;
}
}
m_termid.SetCurSel(0);
m_datatype.SetCurSel(0);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CSecretComm::OnSelchangeComboDatatype()
{
// TODO: Add your control notification handler code here
int ti;
ti = m_datatype.GetCurSel();
if (ti==0)
{
m_statictxt = _T("月份:");
}
else m_statictxt = _T("日期:");
UpdateData(FALSE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -