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

📄 edtlog.cpp

📁   本实例实现在VC下如何编写串口(com port)实例(与串口通信), 对初学者弄懂串口的实现过程是很好的一个实例.以及现实将串口读到的数据记录到一个testlog目录中,以做备份
💻 CPP
字号:
// edtlog.cpp : implementation file
//

#include "stdafx.h"
#include "ComPort.h"
#include "edtlog.h"


#include "ComPortDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// Cedtlog

Cedtlog::Cedtlog()
{
	EnableAutomation();
}

Cedtlog::~Cedtlog()
{
}

void Cedtlog::OnFinalRelease()
{
	// When the last reference for an automation object is released
	// OnFinalRelease is called.  The base class will automatically
	// deletes the object.  Add additional cleanup required for your
	// object before calling the base class.

	CEdit::OnFinalRelease();
}


BEGIN_MESSAGE_MAP(Cedtlog, CEdit)
	//{{AFX_MSG_MAP(Cedtlog)
	ON_WM_CHAR()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

BEGIN_DISPATCH_MAP(Cedtlog, CEdit)
	//{{AFX_DISPATCH_MAP(Cedtlog)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_DISPATCH_MAP
END_DISPATCH_MAP()

// Note: we add support for IID_Iedtlog to support typesafe binding
//  from VBA.  This IID must match the GUID that is attached to the 
//  dispinterface in the .ODL file.

// {43D37375-8514-4E8F-B92F-6C9DDB6B84BC}
static const IID IID_Iedtlog =
{ 0x43d37375, 0x8514, 0x4e8f, { 0xb9, 0x2f, 0x6c, 0x9d, 0xdb, 0x6b, 0x84, 0xbc } };

BEGIN_INTERFACE_MAP(Cedtlog, CEdit)
	INTERFACE_PART(Cedtlog, IID_Iedtlog, Dispatch)
END_INTERFACE_MAP()

/////////////////////////////////////////////////////////////////////////////
// Cedtlog message handlers

void Cedtlog::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	CComPortDlg* pDlg = static_cast<CComPortDlg*>(this->GetParent());
	char c = (char)nChar;
	if(!pDlg->m_bConnected)
	{
		AfxMessageBox("串口没有连接!");
		return;
	}
	pDlg->m_bisonchar = TRUE;
	//MessageBox("ON CHAR");
	pDlg->SendCom(&c, 1);
	
//	CEdit::OnChar(nChar, nRepCnt, nFlags);
}

⌨️ 快捷键说明

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