📄 bcsetupdlg.cpp
字号:
// BCSetupDlg.cpp : implementation file
//
#include "stdafx.h"
#include "SF1553.h"
#include "BCSetupDlg.h"
#include <windowsx.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CBCSetupDlg dialog
CBCSetupDlg::CBCSetupDlg(CWnd* pParent /*=NULL*/)
: CDialog(CBCSetupDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CBCSetupDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CBCSetupDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CBCSetupDlg)
DDX_Control(pDX, IDC_RETRYTIME, m_cbRetryTimes);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CBCSetupDlg, CDialog)
//{{AFX_MSG_MAP(CBCSetupDlg)
ON_BN_CLICKED(IDC_CHECK_RETRYENABLE, OnCheckRetryenable)
ON_BN_CLICKED(IDC_CHECK_FRAMEAUTOREPEN, OnCheckFrameautorepen)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBCSetupDlg message handlers
BOOL CBCSetupDlg::OnInitDialog()
{
CHAR szbuf[64];
CDialog::OnInitDialog();
// TODO: Add extra initialization here
//Retry set
if(g_BCConf.Rty_en)
{
Button_SetCheck(::GetDlgItem(m_hWnd, IDC_CHECK_RETRYENABLE), BST_CHECKED);
//retry times
m_cbRetryTimes.ResetContent();
m_cbRetryTimes.AddString("一次");
m_cbRetryTimes.AddString("二次");
if(g_BCConf.DoubleTry)
m_cbRetryTimes.SetCurSel(1);
else
m_cbRetryTimes.SetCurSel(0);
//Retry when message error
if(g_BCConf.retrycaseconf.Retry_IF_MSGErr)
Button_SetCheck(::GetDlgItem(m_hWnd, IDC_RETRYONERR), BST_CHECKED);
//Retry when status set
if(g_BCConf.retrycaseconf.Retry_IF_StatusSet)
Button_SetCheck(::GetDlgItem(m_hWnd, IDC_RETRYONSTAT), BST_CHECKED);
//change channel when 1st retry
if(g_BCConf.retrychannelconf.Alter_Chan_On_Busy1)
Button_SetCheck(::GetDlgItem(m_hWnd, IDC_CHGCHANNEL1STTIME), BST_CHECKED);
//change channel whent 2cd retry
if(g_BCConf.retrychannelconf.Alter_Chan_On_Busy2)
Button_SetCheck(::GetDlgItem(m_hWnd, IDC_CHGCHANNEL2CDTIME), BST_CHECKED);
}
else
{
Button_SetCheck(::GetDlgItem(m_hWnd, IDC_CHECK_RETRYENABLE), BST_UNCHECKED);
::EnableWindow(::GetDlgItem(m_hWnd, IDC_RETRYTIME), FALSE);
::EnableWindow(::GetDlgItem(m_hWnd, IDC_RETRYONERR), FALSE);
::EnableWindow(::GetDlgItem(m_hWnd, IDC_RETRYONSTAT), FALSE);
::EnableWindow(::GetDlgItem(m_hWnd, IDC_CHGCHANNEL1STTIME), FALSE);
::EnableWindow(::GetDlgItem(m_hWnd, IDC_CHGCHANNEL2CDTIME), FALSE);
}
if(g_BCConf.statussetconf.Stop_On_MSG )
Button_SetCheck(::GetDlgItem(m_hWnd, IDC_STAT_STOPMSG), BST_CHECKED);
if(g_BCConf.statussetconf.Stop_On_Frame)
Button_SetCheck(::GetDlgItem(m_hWnd, IDC_STAT_STOPFRM), BST_CHECKED);
if(g_BCConf.Auto_rep)
{
Button_SetCheck(::GetDlgItem(m_hWnd, IDC_CHECK_FRAMEAUTOREPEN), BST_CHECKED);
memset(szbuf, 0, sizeof(szbuf));
itoa(g_BCConf.Frm_gap_time, szbuf, 10);
::SetWindowText(::GetDlgItem(m_hWnd, IDC_EDIT_BC_FRAMEGAP), szbuf);
memset(szbuf, 0, sizeof(szbuf));
itoa(g_BCConf.Frm_repeat_times, szbuf, 10);
::SetWindowText(::GetDlgItem(m_hWnd, IDC_EDIT_BC_FRAMEREPTIME), szbuf);
}
else
{
Button_SetCheck(::GetDlgItem(m_hWnd, IDC_CHECK_FRAMEAUTOREPEN), BST_UNCHECKED);
::EnableWindow(::GetDlgItem(m_hWnd, IDC_EDIT_BC_FRAMEGAP), FALSE);
::EnableWindow(::GetDlgItem(m_hWnd, IDC_EDIT_BC_FRAMEREPTIME), FALSE);
}
//STOP Message when error
if(g_BCConf.stoponerrconf.MSG_STOP_ON_ERR)
Button_SetCheck(::GetDlgItem(m_hWnd, IDC_STOPMSGONERR), BST_CHECKED);
//STOP Frame when error
if(g_BCConf.stoponerrconf.FRAME_STOP_ON_ERR)
Button_SetCheck(::GetDlgItem(m_hWnd, IDC_STOPFRMONERR), BST_CHECKED);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CBCSetupDlg::OnCheckRetryenable()
{
// TODO: Add your control notification handler code here
if(Button_GetCheck(::GetDlgItem(m_hWnd, IDC_CHECK_RETRYENABLE)) == BST_UNCHECKED)
{
::EnableWindow(::GetDlgItem(m_hWnd, IDC_RETRYTIME), FALSE);
::EnableWindow(::GetDlgItem(m_hWnd, IDC_RETRYONERR), FALSE);
::EnableWindow(::GetDlgItem(m_hWnd, IDC_RETRYONSTAT), FALSE);
::EnableWindow(::GetDlgItem(m_hWnd, IDC_CHGCHANNEL1STTIME), FALSE);
::EnableWindow(::GetDlgItem(m_hWnd, IDC_CHGCHANNEL2CDTIME), FALSE);
}
else
{
::EnableWindow(::GetDlgItem(m_hWnd, IDC_RETRYTIME), TRUE);
m_cbRetryTimes.ResetContent();
m_cbRetryTimes.AddString("一次");
m_cbRetryTimes.AddString("二次");
m_cbRetryTimes.SetCurSel(0);
::EnableWindow(::GetDlgItem(m_hWnd, IDC_RETRYONERR), TRUE);
::EnableWindow(::GetDlgItem(m_hWnd, IDC_RETRYONSTAT), TRUE);
::EnableWindow(::GetDlgItem(m_hWnd, IDC_CHGCHANNEL1STTIME), TRUE);
::EnableWindow(::GetDlgItem(m_hWnd, IDC_CHGCHANNEL2CDTIME), TRUE);
}
}
void CBCSetupDlg::OnCheckFrameautorepen()
{
// TODO: Add your control notification handler code here
if(Button_GetCheck(::GetDlgItem(m_hWnd, IDC_CHECK_FRAMEAUTOREPEN)) == BST_UNCHECKED)
{
::EnableWindow(::GetDlgItem(m_hWnd, IDC_EDIT_BC_FRAMEGAP), FALSE);
::EnableWindow(::GetDlgItem(m_hWnd, IDC_EDIT_BC_FRAMEREPTIME), FALSE);
}
else
{
::EnableWindow(::GetDlgItem(m_hWnd, IDC_EDIT_BC_FRAMEGAP), TRUE);
::EnableWindow(::GetDlgItem(m_hWnd, IDC_EDIT_BC_FRAMEREPTIME), TRUE);
}
}
void CBCSetupDlg::OnOK()
{
CHAR szbuf[64];
// TODO: Add extra validation here
if(Button_GetCheck(::GetDlgItem(m_hWnd, IDC_CHECK_RETRYENABLE)) == BST_UNCHECKED)
{
g_BCConf.Rty_en = FALSE;
g_BCConf.retrychannelconf.Alter_Chan_On_Busy1 = FALSE;
g_BCConf.retrychannelconf.Alter_Chan_On_Busy2 = FALSE;
g_BCConf.DoubleTry = FALSE;
g_BCConf.retrycaseconf.Retry_IF_MSGErr = FALSE;
g_BCConf.retrycaseconf.Retry_IF_StatusSet = FALSE;
}
else
{
g_BCConf.Rty_en = TRUE;
if(m_cbRetryTimes.GetCurSel() == 0)
g_BCConf.DoubleTry = FALSE;
else
g_BCConf.DoubleTry = TRUE;
if(Button_GetCheck(::GetDlgItem(m_hWnd, IDC_RETRYONERR)) == BST_CHECKED)
g_BCConf.retrycaseconf.Retry_IF_MSGErr = TRUE;
else
g_BCConf.retrycaseconf.Retry_IF_MSGErr = FALSE;
if(Button_GetCheck(::GetDlgItem(m_hWnd, IDC_RETRYONSTAT)) == BST_CHECKED)
g_BCConf.retrycaseconf.Retry_IF_StatusSet = TRUE;
else
g_BCConf.retrycaseconf.Retry_IF_StatusSet = FALSE;
if(Button_GetCheck(::GetDlgItem(m_hWnd, IDC_CHGCHANNEL1STTIME)) == BST_CHECKED)
g_BCConf.retrychannelconf.Alter_Chan_On_Busy1 = TRUE;
else
g_BCConf.retrychannelconf.Alter_Chan_On_Busy1 = FALSE;
if(Button_GetCheck(::GetDlgItem(m_hWnd, IDC_CHGCHANNEL2CDTIME)) == BST_CHECKED)
g_BCConf.retrychannelconf.Alter_Chan_On_Busy2 = TRUE;
else
g_BCConf.retrychannelconf.Alter_Chan_On_Busy2 = FALSE;
}
if(Button_GetCheck(::GetDlgItem(m_hWnd, IDC_STAT_STOPMSG)) == BST_CHECKED)
g_BCConf.statussetconf.Stop_On_MSG = TRUE;
else
g_BCConf.statussetconf.Stop_On_MSG = FALSE;
if(Button_GetCheck(::GetDlgItem(m_hWnd, IDC_STAT_STOPFRM)) == BST_CHECKED)
g_BCConf.statussetconf.Stop_On_Frame = TRUE;
else
g_BCConf.statussetconf.Stop_On_Frame = FALSE;
if(Button_GetCheck(::GetDlgItem(m_hWnd, IDC_CHECK_FRAMEAUTOREPEN)) == BST_UNCHECKED)
{
g_BCConf.Auto_rep = FALSE;
g_BCConf.Frm_gap_time = 0;
g_BCConf.Frm_repeat_times = 0;
}
else
{
g_BCConf.Auto_rep = TRUE;
::GetWindowText(::GetDlgItem(m_hWnd, IDC_EDIT_BC_FRAMEGAP), szbuf, sizeof(szbuf));
g_BCConf.Frm_gap_time = atoi(szbuf);
::GetWindowText(::GetDlgItem(m_hWnd, IDC_EDIT_BC_FRAMEREPTIME), szbuf, sizeof(szbuf));
g_BCConf.Frm_repeat_times = atoi(szbuf);
}
if(Button_GetCheck(::GetDlgItem(m_hWnd, IDC_STOPMSGONERR)) == BST_CHECKED)
g_BCConf.stoponerrconf.MSG_STOP_ON_ERR = TRUE;
else
g_BCConf.stoponerrconf.MSG_STOP_ON_ERR = FALSE;
if(Button_GetCheck(::GetDlgItem(m_hWnd, IDC_STOPFRMONERR)) == BST_CHECKED)
g_BCConf.stoponerrconf.FRAME_STOP_ON_ERR = TRUE;
else
g_BCConf.stoponerrconf.FRAME_STOP_ON_ERR = FALSE;
//
if(g_CardHandle != NULL)
{
BC_SetRetryCase (g_CardHandle, &g_BCConf.retrycaseconf);
if(g_BCConf.DoubleTry)
BC_SetRetryNum (g_CardHandle, 2);
else
BC_SetRetryNum (g_CardHandle, 1);
BC_RetryChanSel (g_CardHandle, &g_BCConf.retrychannelconf);
BC_StopOnError (g_CardHandle, &g_BCConf.stoponerrconf);
BC_OnStatusSet (g_CardHandle, &g_BCConf.statussetconf);
BC_FrameAutoRepeat (g_CardHandle, g_BCConf.Auto_rep);
BC_SetFrameGap (g_CardHandle, g_BCConf.Frm_gap_time);
BC_FrameAutoRepeat_Count (g_CardHandle, g_BCConf.Frm_repeat_times);
}
else
{
}
CDialog::OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -