edtlog.cpp

来自「  本实例实现在VC下如何编写串口(com port)实例(与串口通信), 对初」· C++ 代码 · 共 82 行

CPP
82
字号
// 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 + =
减小字号Ctrl + -
显示快捷键?