⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 smsdlg.cpp

📁 PDU解码
💻 CPP
字号:
// SMSDlg.cpp : implementation file
//

#include "stdafx.h"
#include "SMS.h"
#include "SMSDlg.h"
#include "Nokia_SMS.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSMSDlg dialog

CSMSDlg::CSMSDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CSMSDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSMSDlg)
	m_Dest = _T("");
	m_Server = _T("");
	m_Msg = _T("");
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CSMSDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSMSDlg)
	DDX_Control(pDX, IDC_COMBO1, m_Port);
	DDX_Control(pDX, IDC_MSCOMM1, m_Com);
	DDX_Text(pDX, IDC_EDIT2, m_Dest);
	DDX_Text(pDX, IDC_EDIT3, m_Server);
	DDX_Text(pDX, IDC_EDIT4, m_Msg);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CSMSDlg, CDialog)
	//{{AFX_MSG_MAP(CSMSDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSMSDlg message handlers

BOOL CSMSDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);

			
		}
	}

	// 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
	
	// TODO: Add extra initialization here
	m_Dest="";
	m_Port.SetCurSel(0);
	UpdateData(FALSE);
    m_Com.SetCommPort(1);   //选择串口
	m_Com.SetSettings("9600,o,8,1");
	m_Com.SetInputMode(1);  //设置输入方式为二进制方式
	m_Com.SetRThreshold(0);  //设置有一个或一个以上字符产生接收事件
	m_Com.SetSThreshold(0);  //设置不产生发送缓冲空事件
	m_Com.SetInBufferSize(1024);//设置接收缓冲大小
	m_Com.SetInBufferCount(0);//清除接收缓冲
	m_Com.SetOutBufferSize(1024);//设置发送缓冲大小
	m_Com.SetOutBufferCount(0);//清除发送缓冲
	m_Com.SetInputLen(0);//全部读取
	if(m_Com.GetPortOpen()==FALSE)
	{
		m_Com.SetPortOpen(TRUE);
	}
	else
	{
		MessageBox("Can not open the COM port!");
	}
	location=0;
	seq=0;
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CSMSDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CSMSDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
		
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CSMSDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}


void CSMSDlg::OnSelchangeCombo1() 
{
	// TODO: Add your control notification handler code here
	if(m_Com.GetPortOpen()==TRUE)
	{
		m_Com.SetPortOpen(FALSE);
	}
	unsigned int static Index;
	Index=m_Port.GetCurSel();
	m_Com.SetCommPort(Index+1);   //选择串口
	m_Com.SetSettings("9600,n,8,1");
	m_Com.SetInputMode(0);  //设置输入方式为二进制方式
	m_Com.SetRThreshold(1);  //设置有一个或一个以上字符产生接收事件
	m_Com.SetSThreshold(0);  //设置不产生发送缓冲空事件
	m_Com.SetInBufferSize(1024);//设置接收缓冲大小
	m_Com.SetInBufferCount(0);//清除接收缓冲
	m_Com.SetOutBufferSize(1024);//设置发送缓冲大小
	m_Com.SetOutBufferCount(0);//清除发送缓冲
	m_Com.SetInputLen(0);//全部读取
}




void CSMSDlg::OnButton1() 
{
	// TODO: Add your control notification handler code here
/*	m_Com.SetCommPort(1);   //选择串口
	m_Com.SetSettings("9600,o,8,1");
	m_Com.SetInputMode(1);  //设置输入方式为二进制方式
	m_Com.SetRThreshold(12);  //设置有一个或一个以上字符产生接收事件
	m_Com.SetSThreshold(0);  //设置不产生发送缓冲空事件
	m_Com.SetInBufferSize(1024);//设置接收缓冲大小
	m_Com.SetInBufferCount(0);//清除接收缓冲
	m_Com.SetOutBufferSize(1024);//设置发送缓冲大小
	m_Com.SetOutBufferCount(0);//清除发送缓冲
	m_Com.SetInputLen(0);//全部读取
	if(m_Com.GetPortOpen()==FALSE)
	{
		m_Com.SetPortOpen(TRUE);
	}
	else
	{
		MessageBox("Can not open the COM port!");
	}*/
    
    
    UpdateData(TRUE);
	//m_Dest="+8613910234912";
	//m_Src="+8613910234912";
	//m_Server="+8613800100500";
	//m_Msg="lkjjjh";
    SMS.MsgPack(m_Dest,m_Server,m_Msg);
	//SMS.GetMsg(location++);
	//SMS.GetIMEI();
	
	SMS.FramePack(0x00,0x10,0x2,seq++);
	CByteArray SendBuffer;
	int Length=SMS.GetLength();
	SendBuffer.SetSize(Length);
	for(int i=0;i<Length;i++)
	{
		SendBuffer.SetAt(i,SMS.GetAt(i));
	}
	m_Com.SetOutput(COleVariant(SendBuffer));


}

BEGIN_EVENTSINK_MAP(CSMSDlg, CDialog)
    //{{AFX_EVENTSINK_MAP(CSMSDlg)
	ON_EVENT(CSMSDlg, IDC_MSCOMM1, 1 /* OnComm */, OnOnCommMscomm1, VTS_NONE)
	//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()

void CSMSDlg::OnOnCommMscomm1() 
{
	// TODO: Add your control notification handler code here
	VARIANT variant_inp;
	MessageBox("kjklj");
	variant_inp=m_Com.GetInput(); //读缓冲区
	
	m_Com.SetPortOpen(FALSE);
}




⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -