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

📄 timesetdlg.cpp

📁 1553B板卡的源代码,只有购买板卡才能得到的好资料
💻 CPP
字号:
// TimeSetDlg.cpp : implementation file
//

#include "stdafx.h"
#include "sf1553.h"
#include "TimeSetDlg.h"


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

/////////////////////////////////////////////////////////////////////////////
// CTimeSetDlg dialog


CTimeSetDlg::CTimeSetDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CTimeSetDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CTimeSetDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CTimeSetDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CTimeSetDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CTimeSetDlg, CDialog)
	//{{AFX_MSG_MAP(CTimeSetDlg)
	ON_EN_CHANGE(IDC_ATS_ED_TIMEOUT0, OnChangeAtsEdTimeout0)
	ON_EN_KILLFOCUS(IDC_ATS_ED_TIMEOUT0, OnKillfocusAtsEdTimeout0)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTimeSetDlg message handlers

void CTimeSetDlg::OnOK() 
{
	// TODO: Add extra validation here
	int i=0;
	char c[80];

	if (Button_GetCheck(::GetDlgItem(this->m_hWnd, IDC_ATS_CK_TTAG0)) == BST_UNCHECKED)
	{
		g_MiscConf.isNeedTimeTag = FALSE;
	}
	else
	{
		g_MiscConf.isNeedTimeTag = TRUE;
	}

	::GetWindowText(::GetDlgItem(this->m_hWnd, IDC_ATS_ED_TIMEOUT0), c, sizeof(c));
	g_MiscConf.dwTimeOut = (WORD) atoi(c);

	if (g_CardHandle != NULL)
	{
		//	add time tag
		//
		if (!S1553_AddTimeTag(g_CardHandle, g_MiscConf.isNeedTimeTag))
		{
			MessageBox(TEXT("设置板卡时间标签失败!"), TEXT("错误"), MB_OK | MB_ICONERROR);
			return;
		}

		//	setup time out
		//
		if (!S1553_SetResponseTimeout(g_CardHandle, (SHORT)g_MiscConf.dwTimeOut))
		{
			MessageBox(TEXT("设置板卡应答超时时间!"), TEXT("错误"), MB_OK | MB_ICONERROR);
			return;
		}
	}
	else
	{
		// demo mode
	}
	
	CDialog::OnOK();
}

void CTimeSetDlg::OnCancel() 
{
	// TODO: Add extra cleanup here
	
	CDialog::OnCancel();
}

BOOL CTimeSetDlg::OnInitDialog() 
{
	int i=0;
	char c[80];

	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here

	if (g_MiscConf.isNeedTimeTag)
	{
		Button_SetCheck(::GetDlgItem(this->m_hWnd, IDC_ATS_CK_TTAG0), BST_CHECKED);
	}
	else
	{
		Button_SetCheck(::GetDlgItem(this->m_hWnd, IDC_ATS_CK_TTAG0), BST_UNCHECKED);
	}

	itoa(g_MiscConf.dwTimeOut, c, 10);
	::SetWindowText(::GetDlgItem(this->m_hWnd, IDC_ATS_ED_TIMEOUT0), TEXT(c));

	//	Limit edit control Text length
	//
	Edit_LimitText(::GetDlgItem(this->m_hWnd, IDC_ATS_ED_TIMEOUT0), 5);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CTimeSetDlg::OnChangeAtsEdTimeout0() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	char c[80];
	long l=0;

	::GetWindowText(::GetDlgItem(this->m_hWnd, IDC_ATS_ED_TIMEOUT0), c, sizeof(c));

	l = atol(c);

	if (l>0xFFFF)
	{
		ltoa(0xFFFF, c, 10);
		::SetWindowText(::GetDlgItem(this->m_hWnd, IDC_ATS_ED_TIMEOUT0), TEXT(c));
		Edit_SetSel(::GetDlgItem(this->m_hWnd, IDC_ATS_ED_TIMEOUT0), 
					Edit_LineLength(::GetDlgItem(this->m_hWnd, IDC_ATS_ED_TIMEOUT0), -1), 
					Edit_LineLength(::GetDlgItem(this->m_hWnd, IDC_ATS_ED_TIMEOUT0), -1));
		::SetFocus(::GetDlgItem(this->m_hWnd, IDC_ATS_ED_TIMEOUT0));
	}

	
	// TODO: Add your control notification handler code here
	
}

void CTimeSetDlg::OnKillfocusAtsEdTimeout0() 
{
	// TODO: Add your control notification handler code here
	if (Edit_LineLength(::GetDlgItem(this->m_hWnd, IDC_ATS_ED_TIMEOUT0), -1)==0)
	{
		::SetWindowText(::GetDlgItem(this->m_hWnd, IDC_ATS_ED_TIMEOUT0), TEXT("20"));
	}
	else
	{
		char c[80];
		long l=0;

		::GetWindowText(::GetDlgItem(this->m_hWnd, IDC_ATS_ED_TIMEOUT0), c, sizeof(c));

		l = atol(c);

		if (l<20)
		{
			::SetWindowText(::GetDlgItem(this->m_hWnd, IDC_ATS_ED_TIMEOUT0), TEXT("20"));
		}
	}

	
}

⌨️ 快捷键说明

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