📄 celliddlg.cpp
字号:
// cellIDDlg.cpp : implementation file
//
#include "stdafx.h"
#include "cellID.h"
#include "cellIDDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
char* GetCREG( char * comPort );
char* GetCSQ( char * comPort );
/////////////////////////////////////////////////////////////////////////////
// CCellIDDlg dialog
CCellIDDlg::CCellIDDlg(CWnd* pParent /*=NULL*/)
: CDialog(CCellIDDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CCellIDDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CCellIDDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCellIDDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCellIDDlg, CDialog)
//{{AFX_MSG_MAP(CCellIDDlg)
ON_WM_TIMER()
ON_WM_CLOSE()
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCellIDDlg message handlers
char* caFile[500];
int ict=0;
BOOL CCellIDDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
CenterWindow(GetDesktopWindow()); // center to the hpc screen
memset(caFile, 0, sizeof(caFile));
// TODO: Add extra initialization here
SetTimer(123, 3000, NULL);
return TRUE; // return TRUE unless you set the focus to a control
}
typedef struct
{
char c[12];
char iLac[4];
char s[2];
char iId[4];
} TCREG_DATA;
int giLac = 0, giId = 0;
void CCellIDDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
TCREG_DATA* pData = (TCREG_DATA*)GetCREG(NULL);
TCHAR szNum[5];
int iLac = 0, iId = 0;
// LAC
szNum[0] = (unsigned short) pData->iLac[0];
szNum[1] = (unsigned short) pData->iLac[1];
szNum[2] = (unsigned short) pData->iLac[2];
szNum[3] = (unsigned short) pData->iLac[3];
szNum[4] = (unsigned short) '\0';
_stscanf(szNum, TEXT("%x"), &iLac);
// ID
szNum[0] = (unsigned short) pData->iId[0];
szNum[1] = (unsigned short) pData->iId[1];
szNum[2] = (unsigned short) pData->iId[2];
szNum[3] = (unsigned short) pData->iId[3];
szNum[4] = (unsigned short) '\0';
_stscanf(szNum, TEXT("%x"), &iId);
if (iLac != giLac || iId != giId)
{
giId = iId;
giLac = iLac;
TCHAR caOt[50];
wsprintf(caOt, TEXT("区域ID:%d, 基站ID:%d"), iLac, iId);
SetDlgItemText(IDC_stcLab, caOt);
SYSTEMTIME ctm;
GetSystemTime(&ctm);
memset(caOt, 0, sizeof(caOt));
sprintf((char*)caOt, "区域ID:%d, 基站ID:%d, %d-%d-%d:%d-%d-%d\r\n", iLac, iId,
ctm.wYear, ctm.wMonth, ctm.wDay, (ctm.wHour+8)%24, ctm.wMinute, ctm.wSecond);
caFile[ict] = new char[strlen((char*)caOt)+1];
strcpy(caFile[ict], (char*)caOt);
ict++;
}
CDialog::OnTimer(nIDEvent);
}
void CCellIDDlg::OnClose()
{
// TODO: Add your message handler code here and/or call default
CDialog::OnClose();
return;
}
void CCellIDDlg::OnDestroy()
{
FILE* fp = fopen("a.txt", "wr");
for (int i=0; i<ict; i++)
{
fwrite(caFile[i], strlen(caFile[i]), 1, fp);
}
fclose(fp);
fp = NULL;
CDialog::OnDestroy();
// TODO: Add your message handler code here
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -