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

📄 setcommdlg.cpp

📁 M16C Flash Starter Software Ver.2.0.0.46 Source Files.zip是瑞萨的M16C系列单片机的flash烧写程序。
💻 CPP
字号:
// SetCommDlg.cpp : Implementation.
//
// This software can be offered for free and used as necessary to aid 
// in your program developments.
//
// RENESAS TECHNOLOGY CORPORATION, RENESAS SOLUTIONS CORPORATION,
// and related original software developers assume no responsibility 
// for any damage or infringement of any third-party's rights, originating 
// in the use of the following software.
// Please use this software under the agreement and acceptance of these conditions. 
//
// Copyright(C)1998(2003) RENESAS TECHNOLOGY CORPORATION AND RENESAS SOLUTIONS CORPORATION
// ALL RIGHTS RESERVED
//

#include <stdlib.h>

#include "stdafx.h"
#include "M16Cflsh.h"
#include "SetCommDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CSetCommDlg dialog
///////// intialize /////////////////////////////////////////////////////////

DWORD CSetCommDlg::s_strIntervals = DEF_INTERVALS;

/////////////////////////////////////////////////////////////////////////////

CSetCommDlg::CSetCommDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CSetCommDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSetCommDlg)
	m_strBaundRate = _T("");
	m_strIntervals = _T("");
	//}}AFX_DATA_INIT
    BackIntervals(); // add Intervals
}


void CSetCommDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSetCommDlg)
	DDX_CBString(pDX, IDC_COMBO_BAUND_RATE, m_strBaundRate);
	DDX_CBString(pDX, IDC_COMBO_INTAVALS, m_strIntervals);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CSetCommDlg, CDialog)
	//{{AFX_MSG_MAP(CSetCommDlg)
	ON_CBN_CLOSEUP(IDC_COMBO_BAUND_RATE, OnCloseupComboBaundRate)
	ON_CBN_CLOSEUP(IDC_COMBO_INTAVALS, OnCloseupComboIntavals)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////

	// make communication status string.
BOOL CSetCommDlg::SetDispOut(DWORD dwBaudRate, BYTE btByteSize, BYTE btStopBits, BYTE btParity)
{
	TCHAR buff[10];
	ultoa(dwBaudRate, buff, 10);
	m_strBaundRate = buff;	
/*	ltoa(btByteSize, buff, 10);
	m_strByteSize = buff;
	if(ONESTOPBIT == btStopBits)
	{
		m_nStopBit = 0;
	}
	else if(ONE5STOPBITS == btStopBits)
	{
		m_nStopBit = 1;
	}
	else if(TWOSTOPBITS == btStopBits)
	{
		m_nStopBit = 2;
	}
	if(NOPARITY == btParity)
	{
		m_nParity = 0;
	}
	else if(ODDPARITY == btParity)
	{
		m_nParity = 1;
	}
	else if(EVENPARITY == btParity)
	{
		m_nParity = 2;
	}
*/
	return TRUE;
}
	// restore intervals string.
void  CSetCommDlg::BackIntervals(void)
{
	TCHAR buff[10];
	ultoa(s_strIntervals, buff, 10); // add Intervals
	m_strIntervals = buff;

}
	// keep intervals string.
BOOL  CSetCommDlg::KeepIntervals(void)
{
	if(m_strIntervals.IsEmpty())
	{
		return FALSE;
	}
	s_strIntervals = strtoul(m_strIntervals, NULL, 10);
	return TRUE;
}

	// get communication setting.
BOOL CSetCommDlg::GetSetting(DWORD* dwBaudRate, BYTE* btByteSize, BYTE* btStopBits, BYTE* btParity)
{
//	if(m_strBaundRate.IsEmpty() || m_strByteSize.IsEmpty())
	if(m_strBaundRate.IsEmpty())
	{
		return FALSE;
	}	
/*	if('7' != m_strByteSize && '8' != m_strByteSize)
	{
		return FALSE;
	}
*/
	*dwBaudRate = strtoul(m_strBaundRate, NULL, 10);
/*	*btByteSize = strtol(m_strByteSize, NULL, 10);
	if(0 == m_nStopBit)
	{
		*btStopBits = ONESTOPBIT;
	}
	else if(1 == m_nStopBit)
	{
		*btStopBits = ONE5STOPBITS;
	}
	else if(2 == m_nStopBit)
	{
		*btStopBits = TWOSTOPBITS;
	}
	if(0 == m_nParity)
	{
		*btParity = NOPARITY;
	}
	else if(1 == m_nParity)
	{
		*btParity = ODDPARITY;
	}
	else if(2 == m_nParity)
	{
		*btParity = EVENPARITY;
	}
*/
	return TRUE;
}
// get communication setting.
BOOL CSetCommDlg::GetIntervals(DWORD* dwIntervals)
{
	if(m_strIntervals.IsEmpty()) // add Intervals
	{
		return FALSE;
	}
	*dwIntervals = strtoul(m_strIntervals, NULL, 10); 

	return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CSetCommDlg message handler.

void CSetCommDlg::OnOK() 
{
	// TODO:
	UpdateData(TRUE);
    KeepIntervals();
	CDialog::OnOK();
}

void CSetCommDlg::OnCloseupComboBaundRate() 
{
	// TODO: Add the cord for control notice handle to this position.
	
}

void CSetCommDlg::OnCloseupComboIntavals() 
{
	// TODO: Add the cord for control notice handle to this position.
	
}

void CSetCommDlg::OnCancel() 
{
	// TODO: Add the cord for control notice handle to this position

	CDialog::OnCancel();
}

⌨️ 快捷键说明

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