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

📄 comsetdlg.cpp

📁 监视Modbus规约的通讯程序
💻 CPP
字号:
// ComSetDlg.cpp : implementation file
//

#include "stdafx.h"
#include "dongmo.h"
#include "ComSetDlg.h"

#include "Com.h"

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

 CCom g_Com;
extern int g_Address;
/////////////////////////////////////////////////////////////////////////////
// CComSetDlg dialog


CComSetDlg::CComSetDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CComSetDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CComSetDlg)
	m_port = 0;
	m_baud = 3;
	//}}AFX_DATA_INIT
}


void CComSetDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CComSetDlg)
	DDX_CBIndex(pDX, IDC_COMBO_PORT, m_port);
	DDX_CBIndex(pDX, IDC_COMBO_BAUD, m_baud);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CComSetDlg, CDialog)
	//{{AFX_MSG_MAP(CComSetDlg)
	ON_CBN_EDITCHANGE(IDC_COMBO_PORT, OnEditchangeComboPort)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CComSetDlg message handlers

void CComSetDlg::OnOK() 
{

	// TODO: Add extra validation here
	if (!UpdateData())
		return;
   
	CString csPort;
	csPort.Format("COM%d", m_port + 1);
     g_Com.Close();
	if (!g_Com.Open(csPort, 1200 * (1 << m_baud)))
	{
		MessageBox("无法打开通讯口" + csPort + "!", NULL, MB_OK | MB_ICONSTOP);
		return;
	}

//	g_Address = m_Address;


	CDialog::OnOK();
}

void CComSetDlg::OnEditchangeComboPort() 
{
	// TODO: Add your control notification handler code here
	
}

⌨️ 快捷键说明

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