﻿// SettingDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Counter.h"
#include "SettingDlg.h"
#include "afxdialogex.h"
#include "Caio.h"


// CSettingDlg dialog

IMPLEMENT_DYNAMIC(CSettingDlg, CDialogEx)

CSettingDlg::CSettingDlg(CWnd* pParent /*=NULL*/)
	: CDialogEx(IDD_SETTING_DIALOG, pParent)
{

}

CSettingDlg::~CSettingDlg()
{
}

void CSettingDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_CHECK_COMPARE_LOAD, m_compare_load);
	DDX_Control(pDX, IDC_COMBO_SETTING_COMPARE_DATA_NUM, m_compare_data_num);
	DDX_Control(pDX, IDC_COMBO_SETTING_COMPARE_REPEAT, m_compare_repeat);
	DDX_Control(pDX, IDC_EDIT_SETTING_COMPARE_DATA_0, m_compare_data_0);
	DDX_Control(pDX, IDC_EDIT_SETTING_COMPARE_DATA_1, m_compare_data_1);
	DDX_Control(pDX, IDC_EDIT_SETTING_COMPARE_DATA_2, m_compare_data_2);
	DDX_Control(pDX, IDC_EDIT_SETTING_COMPARE_DATA_3, m_compare_data_3);
	DDX_Control(pDX, IDC_EDIT_SETTING_COMPARE_DATA_4, m_compare_data_4);
	DDX_Control(pDX, IDC_CHECK_PRESET_LOAD, m_preset_load);
	DDX_Control(pDX, IDC_COMBO_SETTING_PRESET_DATA_NUM, m_preset_data_num);
	DDX_Control(pDX, IDC_COMBO_SETTING_PRESET_REPEAT, m_preset_repeat);
	DDX_Control(pDX, IDC_EDIT_SETTING_PRESET_DATA_0, m_preset_data_0);
	DDX_Control(pDX, IDC_EDIT_SETTING_PRESET_DATA_1, m_preset_data_1);
	DDX_Control(pDX, IDC_EDIT_SETTING_PRESET_DATA_2, m_preset_data_2);
	DDX_Control(pDX, IDC_EDIT_SETTING_PRESET_DATA_3, m_preset_data_3);
	DDX_Control(pDX, IDC_EDIT_SETTING_PRESET_DATA_4, m_preset_data_4);
}


BEGIN_MESSAGE_MAP(CSettingDlg, CDialogEx)
	ON_BN_CLICKED(IDC_CHECK_COMPARE_LOAD, &CSettingDlg::OnBnClickedCheckCompareLoad)
	ON_CBN_SELCHANGE(IDC_COMBO_SETTING_COMPARE_DATA_NUM, &CSettingDlg::OnCbnSelchangeComboSettingCompareDataNum)
	ON_BN_CLICKED(IDC_CHECK_PRESET_LOAD, &CSettingDlg::OnBnClickedCheckPresetLoad)
	ON_CBN_SELCHANGE(IDC_COMBO_SETTING_PRESET_DATA_NUM, &CSettingDlg::OnCbnSelchangeComboSettingPresetDataNum)
	ON_BN_CLICKED(IDC_BUTTON_OK, &CSettingDlg::OnBnClickedButtonOk)
	ON_BN_CLICKED(IDC_BUTTON_CANCEL, &CSettingDlg::OnBnClickedButtonCancel)
END_MESSAGE_MAP()

//----------------------------------------
// Declaration of global variables
//----------------------------------------
extern short	g_id;
extern short	g_channel;
extern long		g_compare_data_num;
extern short	g_compare_repeat;
extern long		g_compare_data_0;
extern long		g_compare_data_1;
extern long		g_compare_data_2;
extern long		g_compare_data_3;
extern long		g_compare_data_4;
extern long		g_preset_data_num;
extern short	g_preset_repeat;
extern long		g_preset_data_0;
extern long		g_preset_data_1;
extern long		g_preset_data_2;
extern long		g_preset_data_3;
extern long		g_preset_data_4;

// CSettingDlg message handlers

BOOL CSettingDlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();


	TCHAR	text_temp[256];		// For temporary storage of text
	char	error_string[256];	// Error code string
	CString	text_string;		// For updating the textbox
	CString	message_string;		// For displaying message
	long	ret;				// For return code
	long	index;				// Index of combobox
	short	cnt_mode;			// Operation mode
	short	err_flag;			// Function execution error flag

	//----------------------------------------
	// Initialize parameters
	//----------------------------------------
	err_flag	= 0;
	//----------------------------------------
	// Set the counter operation as comparison count match occurs
	//----------------------------------------
	ret	= AioGetCntComparisonMode(g_id, g_channel, &cnt_mode);
	//----------------------------------------
	// Abnormal termination process
	//----------------------------------------
	if(ret != 0){
		//--------------------
		// Get error string
		//--------------------
		AioGetErrorString(ret, error_string);
		//--------------------
		// Display message
		//--------------------
		wsprintf(text_temp, _T("%S"), error_string);
		message_string.Format(_T("AioGetCntComparisonMode = %d : %s\n\n*The display could not be updated since an error occurred."), ret, text_temp);
		err_flag	= 1;
		//----------------------------------------
		// Set comparison count
		//----------------------------------------
		m_compare_load.SetCheck(BST_UNCHECKED);
		//----------------------------------------
		// Set comparison match preset
		//----------------------------------------
		m_preset_load.SetCheck(BST_UNCHECKED);
	//----------------------------------------
	// Normal termination process
	//----------------------------------------
	}else{
		//--------------------
		// Set operation mode
		//--------------------
		switch(cnt_mode){
		case 0:
			//----------------------------------------
			// Set comparison count
			//----------------------------------------
			m_compare_load.SetCheck(BST_UNCHECKED);
			//----------------------------------------
			// Set comparison match preset
			//----------------------------------------
			m_preset_load.SetCheck(BST_UNCHECKED);
			break;
		case CNT_LOADPRESET:
			//----------------------------------------
			// Set comparison count
			//----------------------------------------
			m_compare_load.SetCheck(BST_UNCHECKED);
			//----------------------------------------
			// Set comparison match preset
			//----------------------------------------
			m_preset_load.SetCheck(BST_CHECKED);
			break;
		case CNT_LOADCOMP:
			//----------------------------------------
			// Set comparison count
			//----------------------------------------
			m_compare_load.SetCheck(BST_CHECKED);
			//----------------------------------------
			// Set comparison match preset
			//----------------------------------------
			m_preset_load.SetCheck(BST_UNCHECKED);
			break;
		case (CNT_LOADPRESET | CNT_LOADCOMP):
			//----------------------------------------
			// Set comparison count
			//----------------------------------------
			m_compare_load.SetCheck(BST_CHECKED);
			//----------------------------------------
			// Set comparison match preset
			//----------------------------------------
			m_preset_load.SetCheck(BST_CHECKED);
			break;
		default:
			//----------------------------------------
			// Set comparison count
			//----------------------------------------
			m_compare_load.SetCheck(BST_UNCHECKED);
			//----------------------------------------
			// Set comparison match preset
			//----------------------------------------
			m_preset_load.SetCheck(BST_UNCHECKED);
			break;
		}
	}
	//----------------------------------------
	// Updated available controls by operation mode
	//----------------------------------------
	OnBnClickedCheckCompareLoad();
	OnBnClickedCheckPresetLoad();
	//----------------------------------------
	// Comparison Count Set: Create the combobox for the number of setting data
	//----------------------------------------
	m_compare_data_num.AddString(_T("1"));
	m_compare_data_num.AddString(_T("2"));
	m_compare_data_num.AddString(_T("3"));
	m_compare_data_num.AddString(_T("4"));
	m_compare_data_num.AddString(_T("5"));
	//----------------------------------------
	// Comparison Count Set: Change the selection of the combobox for the number of setting data
	//----------------------------------------
	index	= (g_compare_data_num - 1);
	m_compare_data_num.SetCurSel(index);
	if((cnt_mode & CNT_LOADCOMP) == CNT_LOADCOMP){
		OnCbnSelchangeComboSettingCompareDataNum();
	}
	//----------------------------------------
	// Comparison Count Set: Create the combobox for the repeat setting
	//----------------------------------------
	m_compare_repeat.AddString(_T("Not repeat"));
	m_compare_repeat.AddString(_T("Repeat"));
	//----------------------------------------
	// Comparison Count Set: Change the selection of the combobox for the repeat setting
	//----------------------------------------
	index	= g_compare_repeat;
	m_compare_repeat.SetCurSel(index);
	//----------------------------------------
	// Comparison Count Set: Update comparison count data
	//----------------------------------------
	text_string.Format(_T("%ld"), g_compare_data_0);
	m_compare_data_0.SetWindowTextW(text_string);
	text_string.Format(_T("%ld"), g_compare_data_1);
	m_compare_data_1.SetWindowTextW(text_string);
	text_string.Format(_T("%ld"), g_compare_data_2);
	m_compare_data_2.SetWindowTextW(text_string);
	text_string.Format(_T("%ld"), g_compare_data_3);
	m_compare_data_3.SetWindowTextW(text_string);
	text_string.Format(_T("%ld"), g_compare_data_4);
	m_compare_data_4.SetWindowTextW(text_string);
	//----------------------------------------
	// Comparison Match Preset Set: Create the combobox for the number of setting data
	//----------------------------------------
	m_preset_data_num.AddString(_T("1"));
	m_preset_data_num.AddString(_T("2"));
	m_preset_data_num.AddString(_T("3"));
	m_preset_data_num.AddString(_T("4"));
	m_preset_data_num.AddString(_T("5"));
	//----------------------------------------
	// Comparison Match Preset Set: Change the selection of the combobox for the number of setting data
	//----------------------------------------
	index	= (g_preset_data_num - 1);
	m_preset_data_num.SetCurSel(index);
	if((cnt_mode & CNT_LOADPRESET) == CNT_LOADPRESET){
		OnCbnSelchangeComboSettingPresetDataNum();
	}
	//----------------------------------------
	// Comparison Match Preset Set: Create the combobox for the repeat setting
	//----------------------------------------
	m_preset_repeat.AddString(_T("Not repeat"));
	m_preset_repeat.AddString(_T("Repeat"));
	//----------------------------------------
	// Comparison Match Preset Set: Change the selection of the combobox for the repeat setting
	//----------------------------------------
	index	= g_preset_repeat;
	m_preset_repeat.SetCurSel(index);
	//----------------------------------------
	// Comparison Match Preset Set: Update preset data
	//----------------------------------------
	text_string.Format(_T("%ld"), g_preset_data_0);
	m_preset_data_0.SetWindowTextW(text_string);
	text_string.Format(_T("%ld"), g_preset_data_1);
	m_preset_data_1.SetWindowTextW(text_string);
	text_string.Format(_T("%ld"), g_preset_data_2);
	m_preset_data_2.SetWindowTextW(text_string);
	text_string.Format(_T("%ld"), g_preset_data_3);
	m_preset_data_3.SetWindowTextW(text_string);
	text_string.Format(_T("%ld"), g_preset_data_4);
	m_preset_data_4.SetWindowTextW(text_string);
	//----------------------------------------
	// Display message if an error occurs
	//----------------------------------------
	if(err_flag != 0){
		MessageBox(message_string, _T("Error"), MB_OK);
	}
	return TRUE;  // return TRUE unless you set the focus to a control
				  // EXCEPTION: OCX Property Pages should return FALSE
}

//================================================================================
// It is the process when the Comparison Count Set checkbox is clicked
// Update available controls
//================================================================================
void CSettingDlg::OnBnClickedCheckCompareLoad()
{
	//----------------------------------------
	// Update available controls
	//----------------------------------------
	if(m_compare_load.GetCheck() == BST_CHECKED){
		m_compare_data_num.EnableWindow(TRUE);
		m_compare_repeat.EnableWindow(TRUE);
		m_compare_data_0.EnableWindow(TRUE);
		m_compare_data_1.EnableWindow(TRUE);
		m_compare_data_2.EnableWindow(TRUE);
		m_compare_data_3.EnableWindow(TRUE);
		m_compare_data_4.EnableWindow(TRUE);
		OnCbnSelchangeComboSettingCompareDataNum();
	}else{
		m_compare_data_num.EnableWindow(FALSE);
		m_compare_repeat.EnableWindow(FALSE);
		m_compare_data_0.EnableWindow(FALSE);
		m_compare_data_1.EnableWindow(FALSE);
		m_compare_data_2.EnableWindow(FALSE);
		m_compare_data_3.EnableWindow(FALSE);
		m_compare_data_4.EnableWindow(FALSE);
	}
}

//================================================================================
// It is the process when the Number of Setting Data combobox of Comparison Count Set is changed
// Update available controls
//================================================================================
void CSettingDlg::OnCbnSelchangeComboSettingCompareDataNum()
{
	short	index;				// Index of combobox
	short	data_num;			// Number of setting data

	//----------------------------------------
	// Get the index of number of data from combobox
	//----------------------------------------
	index		= m_compare_data_num.GetCurSel();
	//----------------------------------------
	// Branch processing by number of data
	//----------------------------------------
	data_num	= (index + 1);
	switch(data_num){
	case 1:
		m_compare_data_0.EnableWindow(TRUE);
		m_compare_data_1.EnableWindow(FALSE);
		m_compare_data_2.EnableWindow(FALSE);
		m_compare_data_3.EnableWindow(FALSE);
		m_compare_data_4.EnableWindow(FALSE);
		break;
	case 2:
		m_compare_data_0.EnableWindow(TRUE);
		m_compare_data_1.EnableWindow(TRUE);
		m_compare_data_2.EnableWindow(FALSE);
		m_compare_data_3.EnableWindow(FALSE);
		m_compare_data_4.EnableWindow(FALSE);
		break;
	case 3:
		m_compare_data_0.EnableWindow(TRUE);
		m_compare_data_1.EnableWindow(TRUE);
		m_compare_data_2.EnableWindow(TRUE);
		m_compare_data_3.EnableWindow(FALSE);
		m_compare_data_4.EnableWindow(FALSE);
		break;
	case 4:
		m_compare_data_0.EnableWindow(TRUE);
		m_compare_data_1.EnableWindow(TRUE);
		m_compare_data_2.EnableWindow(TRUE);
		m_compare_data_3.EnableWindow(TRUE);
		m_compare_data_4.EnableWindow(FALSE);
		break;
	case 5:
		m_compare_data_0.EnableWindow(TRUE);
		m_compare_data_1.EnableWindow(TRUE);
		m_compare_data_2.EnableWindow(TRUE);
		m_compare_data_3.EnableWindow(TRUE);
		m_compare_data_4.EnableWindow(TRUE);
		break;
	default:
		m_compare_data_0.EnableWindow(TRUE);
		m_compare_data_1.EnableWindow(FALSE);
		m_compare_data_2.EnableWindow(FALSE);
		m_compare_data_3.EnableWindow(FALSE);
		m_compare_data_4.EnableWindow(FALSE);
		break;
	}
}

//================================================================================
// It is the process when the Comparison Match Preset Set checkbox is clicked
// Update available controls
//================================================================================
void CSettingDlg::OnBnClickedCheckPresetLoad()
{
	//----------------------------------------
	// Update available controls
	//----------------------------------------
	if(m_preset_load.GetCheck() == BST_CHECKED){
		m_preset_data_num.EnableWindow(TRUE);
		m_preset_repeat.EnableWindow(TRUE);
		m_preset_data_0.EnableWindow(TRUE);
		m_preset_data_1.EnableWindow(TRUE);
		m_preset_data_2.EnableWindow(TRUE);
		m_preset_data_3.EnableWindow(TRUE);
		m_preset_data_4.EnableWindow(TRUE);
		OnCbnSelchangeComboSettingPresetDataNum();
	}else{
		m_preset_data_num.EnableWindow(FALSE);
		m_preset_repeat.EnableWindow(FALSE);
		m_preset_data_0.EnableWindow(FALSE);
		m_preset_data_1.EnableWindow(FALSE);
		m_preset_data_2.EnableWindow(FALSE);
		m_preset_data_3.EnableWindow(FALSE);
		m_preset_data_4.EnableWindow(FALSE);
	}
}

//================================================================================
// It is the process when the Number of Setting Data combobox of Comparison Match Preset Set is changed
// Update available controls
//================================================================================
void CSettingDlg::OnCbnSelchangeComboSettingPresetDataNum()
{
	short	index;				// Index of combobox
	short	data_num;			// Number of setting data

	//----------------------------------------
	// Get the index of number of data from combobox
	//----------------------------------------
	index		= m_preset_data_num.GetCurSel();
	//----------------------------------------
	// Branch processing by number of data
	//----------------------------------------
	data_num	= (index + 1);
	switch(data_num){
	case 1:
		m_preset_data_0.EnableWindow(TRUE);
		m_preset_data_1.EnableWindow(FALSE);
		m_preset_data_2.EnableWindow(FALSE);
		m_preset_data_3.EnableWindow(FALSE);
		m_preset_data_4.EnableWindow(FALSE);
		break;
	case 2:
		m_preset_data_0.EnableWindow(TRUE);
		m_preset_data_1.EnableWindow(TRUE);
		m_preset_data_2.EnableWindow(FALSE);
		m_preset_data_3.EnableWindow(FALSE);
		m_preset_data_4.EnableWindow(FALSE);
		break;
	case 3:
		m_preset_data_0.EnableWindow(TRUE);
		m_preset_data_1.EnableWindow(TRUE);
		m_preset_data_2.EnableWindow(TRUE);
		m_preset_data_3.EnableWindow(FALSE);
		m_preset_data_4.EnableWindow(FALSE);
		break;
	case 4:
		m_preset_data_0.EnableWindow(TRUE);
		m_preset_data_1.EnableWindow(TRUE);
		m_preset_data_2.EnableWindow(TRUE);
		m_preset_data_3.EnableWindow(TRUE);
		m_preset_data_4.EnableWindow(FALSE);
		break;
	case 5:
		m_preset_data_0.EnableWindow(TRUE);
		m_preset_data_1.EnableWindow(TRUE);
		m_preset_data_2.EnableWindow(TRUE);
		m_preset_data_3.EnableWindow(TRUE);
		m_preset_data_4.EnableWindow(TRUE);
		break;
	default:
		m_preset_data_0.EnableWindow(TRUE);
		m_preset_data_1.EnableWindow(FALSE);
		m_preset_data_2.EnableWindow(FALSE);
		m_preset_data_3.EnableWindow(FALSE);
		m_preset_data_4.EnableWindow(FALSE);
		break;
	}
}

//================================================================================
// It is the process when the OK button is clicked
// Set counter
//================================================================================
void CSettingDlg::OnBnClickedButtonOk()
{
	TCHAR	text_temp[256];		// For temporary storage of text
	char	error_string[256];	// Error code string
	CString	text_string;		// For updating the textbox
	long	ret;				// For return code
	short	cnt_mode;			// Operation mode
	long	index;				// Index of combobox
	long	comparison_data[8];	// Comparison count data
	long	preset_data[8];		// Preset data of counter

	//----------------------------------------
	// Get the counter operation mode
	//----------------------------------------
	cnt_mode	= (m_preset_load.GetCheck() == BST_CHECKED ? CNT_LOADPRESET : 0) | (m_compare_load.GetCheck() == BST_CHECKED ? CNT_LOADCOMP : 0);
	//----------------------------------------
	// Set the counter operation mode
	//----------------------------------------
	ret	= AioSetCntComparisonMode(g_id, g_channel, cnt_mode);
	//----------------------------------------
	// Error process
	//----------------------------------------
	//--------------------
	// Exit the process if not completed successfully
	//--------------------
	if(ret != 0){
		//--------------------
		// Get error string
		//--------------------
		AioGetErrorString(ret, error_string);
		//--------------------
		// Display message
		//--------------------
		wsprintf(text_temp, _T("%S"), error_string);
		text_string.Format(_T("AioSetCntComparisonMode = %d : %s"), ret, text_temp);
		MessageBox(text_string, _T("Error"), MB_OK);
		return;
	}
	//----------------------------------------
	// Set the comparison count data
	//----------------------------------------
	if(m_compare_load.GetCheck() == BST_CHECKED){
		//----------------------------------------
		// Get the index of number of data from combobox
		//----------------------------------------
		index				= m_compare_data_num.GetCurSel();
		g_compare_data_num	= (index + 1);
		//----------------------------------------
		// Get counter comparison count data from textbox
		//----------------------------------------
		m_compare_data_0.GetWindowTextW(text_temp, _countof(text_temp));
		_stscanf_s(text_temp, _T("%ld"), &g_compare_data_0);
		comparison_data[0]	= g_compare_data_0;
		m_compare_data_1.GetWindowTextW(text_temp, _countof(text_temp));
		_stscanf_s(text_temp, _T("%ld"), &g_compare_data_1);
		comparison_data[1]	= g_compare_data_1;
		m_compare_data_2.GetWindowTextW(text_temp, _countof(text_temp));
		_stscanf_s(text_temp, _T("%ld"), &g_compare_data_2);
		comparison_data[2]	= g_compare_data_2;
		m_compare_data_3.GetWindowTextW(text_temp, _countof(text_temp));
		_stscanf_s(text_temp, _T("%ld"), &g_compare_data_3);
		comparison_data[3]	= g_compare_data_3;
		m_compare_data_4.GetWindowTextW(text_temp, _countof(text_temp));
		_stscanf_s(text_temp, _T("%ld"), &g_compare_data_4);
		comparison_data[4]	= g_compare_data_4;
		//----------------------------------------
		// Get the index of the repeat setting from combobox
		//----------------------------------------
		index				= m_compare_repeat.GetCurSel();
		g_compare_repeat	= (short)index;
		//----------------------------------------
		// Set the next comparison count value loaded after comparison count match
		//----------------------------------------
		ret	= AioSetCntComparisonReg(g_id, g_channel, g_compare_data_num, &comparison_data[0], g_compare_repeat);
		//----------------------------------------
		// Error process
		//----------------------------------------
		//--------------------
		// Exit the process if not completed successfully
		//--------------------
		if(ret != 0){
			//--------------------
			// Get error string
			//--------------------
			AioGetErrorString(ret, error_string);
			//--------------------
			// Display message
			//--------------------
			wsprintf(text_temp, _T("%S"), error_string);
			text_string.Format(_T("AioSetCntComparisonReg = %d : %s"), ret, text_temp);
			MessageBox(text_string, _T("Error"), MB_OK);
			return;
		}
	}
	//----------------------------------------
	// Set the preset load data
	//----------------------------------------
	if(m_preset_load.GetCheck() == BST_CHECKED){
		//----------------------------------------
		// Get the index of number of data from combobox
		//----------------------------------------
		index				= m_preset_data_num.GetCurSel();
		g_preset_data_num	= (index + 1);
		//----------------------------------------
		// Get counter preset data from textbox
		//----------------------------------------
		m_preset_data_0.GetWindowTextW(text_temp, _countof(text_temp));
		_stscanf_s(text_temp, _T("%ld"), &g_preset_data_0);
		preset_data[0]	= g_preset_data_0;
		m_preset_data_1.GetWindowTextW(text_temp, _countof(text_temp));
		_stscanf_s(text_temp, _T("%ld"), &g_preset_data_1);
		preset_data[1]	= g_preset_data_1;
		m_preset_data_2.GetWindowTextW(text_temp, _countof(text_temp));
		_stscanf_s(text_temp, _T("%ld"), &g_preset_data_2);
		preset_data[2]	= g_preset_data_2;
		m_preset_data_3.GetWindowTextW(text_temp, _countof(text_temp));
		_stscanf_s(text_temp, _T("%ld"), &g_preset_data_3);
		preset_data[3]	= g_preset_data_3;
		m_preset_data_4.GetWindowTextW(text_temp, _countof(text_temp));
		_stscanf_s(text_temp, _T("%ld"), &g_preset_data_4);
		preset_data[4]	= g_preset_data_4;
		//----------------------------------------
		// Get the index of the repeat setting from combobox
		//----------------------------------------
		index				= m_preset_repeat.GetCurSel();
		g_preset_repeat		= (short)index;
		//----------------------------------------
		// Set the preset value loaded after the comparison count match
		//----------------------------------------
		ret	= AioSetCntPresetReg(g_id, g_channel, g_preset_data_num, &preset_data[0], g_preset_repeat);
		//----------------------------------------
		// Error process
		//----------------------------------------
		//--------------------
		// Exit the process if not completed successfully
		//--------------------
		if(ret != 0){
			//--------------------
			// Get error string
			//--------------------
			AioGetErrorString(ret, error_string);
			//--------------------
			// Display message
			//--------------------
			wsprintf(text_temp, _T("%S"), error_string);
			text_string.Format(_T("AioSetCntPresetReg = %d : %s"), ret, text_temp);
			MessageBox(text_string, _T("Error"), MB_OK);
			return;
		}
	}
	//----------------------------------------
	// OK process
	//----------------------------------------
	CDialogEx::OnOK();
}

//================================================================================
// It is the process when the Close button is clicked
// Terminate the dialog
//================================================================================
void CSettingDlg::OnBnClickedButtonCancel()
{
	//----------------------------------------
	// Cancel process
	//----------------------------------------
	CDialogEx::OnCancel();
}
