// DiCounterDlg.cpp : implementation file
//

#include "stdafx.h"
#include "DiCounter.h"
#include "DiCounterDlg.h"
#include "CDio.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CDiCounterDlg dialog

//==========================================
// Global variable
//==========================================
short	dev_id;					// Device ID
short	count_ch_num;			// Number of counter channels in the device


CDiCounterDlg::CDiCounterDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CDiCounterDlg::IDD, pParent)
{
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CDiCounterDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_EDIT_DEVICE_NAME, m_DeviceName);
	DDX_Control(pDX, IDC_COMBO_COUNT_EDGE0, m_CountEdge0);
	DDX_Control(pDX, IDC_COMBO_COUNT_EDGE1, m_CountEdge1);
	DDX_Control(pDX, IDC_COMBO_COUNT_EDGE2, m_CountEdge2);
	DDX_Control(pDX, IDC_COMBO_COUNT_EDGE3, m_CountEdge3);
	DDX_Control(pDX, IDC_COMBO_COUNT_EDGE4, m_CountEdge4);
	DDX_Control(pDX, IDC_COMBO_COUNT_EDGE5, m_CountEdge5);
	DDX_Control(pDX, IDC_COMBO_COUNT_EDGE6, m_CountEdge6);
	DDX_Control(pDX, IDC_COMBO_COUNT_EDGE7, m_CountEdge7);
	DDX_Control(pDX, IDC_EDIT_CMP_COUNT_VAL0, m_CompareCountValue0);
	DDX_Control(pDX, IDC_EDIT_CMP_COUNT_VAL1, m_CompareCountValue1);
	DDX_Control(pDX, IDC_EDIT_CMP_COUNT_VAL2, m_CompareCountValue2);
	DDX_Control(pDX, IDC_EDIT_CMP_COUNT_VAL3, m_CompareCountValue3);
	DDX_Control(pDX, IDC_EDIT_CMP_COUNT_VAL4, m_CompareCountValue4);
	DDX_Control(pDX, IDC_EDIT_CMP_COUNT_VAL5, m_CompareCountValue5);
	DDX_Control(pDX, IDC_EDIT_CMP_COUNT_VAL6, m_CompareCountValue6);
	DDX_Control(pDX, IDC_EDIT_CMP_COUNT_VAL7, m_CompareCountValue7);
	DDX_Control(pDX, IDC_EDIT_PRESET_VAL0, m_PresetValue0);
	DDX_Control(pDX, IDC_EDIT_PRESET_VAL1, m_PresetValue1);
	DDX_Control(pDX, IDC_EDIT_PRESET_VAL2, m_PresetValue2);
	DDX_Control(pDX, IDC_EDIT_PRESET_VAL3, m_PresetValue3);
	DDX_Control(pDX, IDC_EDIT_PRESET_VAL4, m_PresetValue4);
	DDX_Control(pDX, IDC_EDIT_PRESET_VAL5, m_PresetValue5);
	DDX_Control(pDX, IDC_EDIT_PRESET_VAL6, m_PresetValue6);
	DDX_Control(pDX, IDC_EDIT_PRESET_VAL7, m_PresetValue7);
	DDX_Control(pDX, IDC_EDIT_COUNT_VAL0, m_CountValue0);
	DDX_Control(pDX, IDC_EDIT_COUNT_VAL1, m_CountValue1);
	DDX_Control(pDX, IDC_EDIT_COUNT_VAL2, m_CountValue2);
	DDX_Control(pDX, IDC_EDIT_COUNT_VAL3, m_CountValue3);
	DDX_Control(pDX, IDC_EDIT_COUNT_VAL4, m_CountValue4);
	DDX_Control(pDX, IDC_EDIT_COUNT_VAL5, m_CountValue5);
	DDX_Control(pDX, IDC_EDIT_COUNT_VAL6, m_CountValue6);
	DDX_Control(pDX, IDC_EDIT_COUNT_VAL7, m_CountValue7);
	DDX_Control(pDX, IDC_EDIT_COUNT_STATUS0, m_CountStatus0);
	DDX_Control(pDX, IDC_EDIT_COUNT_STATUS1, m_CountStatus1);
	DDX_Control(pDX, IDC_EDIT_COUNT_STATUS2, m_CountStatus2);
	DDX_Control(pDX, IDC_EDIT_COUNT_STATUS3, m_CountStatus3);
	DDX_Control(pDX, IDC_EDIT_COUNT_STATUS4, m_CountStatus4);
	DDX_Control(pDX, IDC_EDIT_COUNT_STATUS5, m_CountStatus5);
	DDX_Control(pDX, IDC_EDIT_COUNT_STATUS6, m_CountStatus6);
	DDX_Control(pDX, IDC_EDIT_COUNT_STATUS7, m_CountStatus7);
	DDX_Control(pDX, IDC_EDIT_RETURN_CODE, m_Ret);
}

BEGIN_MESSAGE_MAP(CDiCounterDlg, CDialog)
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	//}}AFX_MSG_MAP
	ON_BN_CLICKED(IDC_BUTTON_DIO_INIT, &CDiCounterDlg::OnBnClickedButtonDioInit)
	ON_BN_CLICKED(IDC_BUTTON_DIO_SET_COUNT_EDGE, &CDiCounterDlg::OnBnClickedButtonDioSetCountEdge)
	ON_BN_CLICKED(IDC_BUTTON_DIO_SET_COUNT_MATCH_VALUE, &CDiCounterDlg::OnBnClickedButtonDioSetCountMatchValue)
	ON_BN_CLICKED(IDC_BUTTON_DIO_START_COUNT, &CDiCounterDlg::OnBnClickedButtonDioStartCount)
	ON_BN_CLICKED(IDC_BUTTON_DIO_READ_COUNT, &CDiCounterDlg::OnBnClickedButtonDioReadCount)
	ON_BN_CLICKED(IDC_BUTTON_DIO_GET_COUNT_STATUS, &CDiCounterDlg::OnBnClickedButtonDioGetCountStatus)
	ON_BN_CLICKED(IDC_BUTTON_DIO_COUNT_PRESET, &CDiCounterDlg::OnBnClickedButtonDioCountPreset)
	ON_BN_CLICKED(IDC_BUTTON_DIO_STOP_COUNT, &CDiCounterDlg::OnBnClickedButtonDioStopCount)
	ON_BN_CLICKED(IDC_BUTTON_DIO_EXIT, &CDiCounterDlg::OnBnClickedButtonDioExit)
	ON_BN_CLICKED(IDC_BUTTON_EXIT, &CDiCounterDlg::OnBnClickedButtonExit)
END_MESSAGE_MAP()


// CDiCounterDlg message handlers

//=========================================================
// Diaglog initialization
//=========================================================
BOOL CDiCounterDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon


	//-----------------------------------
	// Control array settings
	//-----------------------------------
	//-----------------------------------
	// Count edge control
	//-----------------------------------
	m_CountEdge[0]			= &m_CountEdge0;
	m_CountEdge[1]			= &m_CountEdge1;
	m_CountEdge[2]			= &m_CountEdge2;
	m_CountEdge[3]			= &m_CountEdge3;
	m_CountEdge[4]			= &m_CountEdge4;
	m_CountEdge[5]			= &m_CountEdge5;
	m_CountEdge[6]			= &m_CountEdge6;
	m_CountEdge[7]			= &m_CountEdge7;
	//-----------------------------------
	// Comparison count value control
	//-----------------------------------
	m_CompareCountValue[0]	= &m_CompareCountValue0;
	m_CompareCountValue[1]	= &m_CompareCountValue1;
	m_CompareCountValue[2]	= &m_CompareCountValue2;
	m_CompareCountValue[3]	= &m_CompareCountValue3;
	m_CompareCountValue[4]	= &m_CompareCountValue4;
	m_CompareCountValue[5]	= &m_CompareCountValue5;
	m_CompareCountValue[6]	= &m_CompareCountValue6;
	m_CompareCountValue[7]	= &m_CompareCountValue7;
	//-----------------------------------
	// Preset value control
	//-----------------------------------
	m_PresetValue[0]		= &m_PresetValue0;
	m_PresetValue[1]		= &m_PresetValue1;
	m_PresetValue[2]		= &m_PresetValue2;
	m_PresetValue[3]		= &m_PresetValue3;
	m_PresetValue[4]		= &m_PresetValue4;
	m_PresetValue[5]		= &m_PresetValue5;
	m_PresetValue[6]		= &m_PresetValue6;
	m_PresetValue[7]		= &m_PresetValue7;
	//-----------------------------------
	// Count value control
	//-----------------------------------
	m_CountValue[0]			= &m_CountValue0;
	m_CountValue[1]			= &m_CountValue1;
	m_CountValue[2]			= &m_CountValue2;
	m_CountValue[3]			= &m_CountValue3;
	m_CountValue[4]			= &m_CountValue4;
	m_CountValue[5]			= &m_CountValue5;
	m_CountValue[6]			= &m_CountValue6;
	m_CountValue[7]			= &m_CountValue7;
	//-----------------------------------
	// Count status control
	//-----------------------------------
	m_CountStatus[0]		= &m_CountStatus0;
	m_CountStatus[1]		= &m_CountStatus1;
	m_CountStatus[2]		= &m_CountStatus2;
	m_CountStatus[3]		= &m_CountStatus3;
	m_CountStatus[4]		= &m_CountStatus4;
	m_CountStatus[5]		= &m_CountStatus5;
	m_CountStatus[6]		= &m_CountStatus6;
	m_CountStatus[7]		= &m_CountStatus7;

	//-----------------------------------
	// Screen display initialization
	//-----------------------------------
	short	ch_no;
	TCHAR	cstr[256];

	//-----------------------------------
	// Device name
	//-----------------------------------
	m_DeviceName.SetWindowText(_T("DIO000"));
	//-----------------------------------
	// For each channel
	//-----------------------------------
	for(ch_no = 0; ch_no < DISP_MAX_COUNT_CH; ch_no++){
		//-----------------------------------
		// Count edge control
		//-----------------------------------
		m_CountEdge[ch_no]->AddString(_T("Rising"));
		m_CountEdge[ch_no]->AddString(_T("Falling"));
		m_CountEdge[ch_no]->AddString(_T("Both"));
		m_CountEdge[ch_no]->SelectString(-1, _T("Rising"));
		//-----------------------------------
		// Comparison count value control
		//-----------------------------------
		wsprintf(cstr, _T("%u"), ((ch_no + 1) * 100));
		m_CompareCountValue[ch_no]->SetWindowText(cstr);
		//-----------------------------------
		// Preset value control
		//-----------------------------------
		wsprintf(cstr, _T("%u"), (ch_no * 100));
		m_PresetValue[ch_no]->SetWindowText(cstr);
		//-----------------------------------
		// Count value control
		//-----------------------------------
		m_CountValue[ch_no]->SetWindowText(_T("-"));
		//-----------------------------------
		// Count status control
		//-----------------------------------
		m_CountStatus[ch_no]->SetWindowText(_T("-"));
	}

	return TRUE;  // return TRUE  unless you set the focus to a control
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CDiCounterDlg::OnPaint()
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this function to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CDiCounterDlg::OnQueryDragIcon()
{
	return static_cast<HCURSOR>(m_hIcon);
}


//=========================================================
// DioInit()
//=========================================================
void CDiCounterDlg::OnBnClickedButtonDioInit()
{
	long	ret;
	char	device_name[100];
	TCHAR	sz_device_name[100];
	char	error_string[100];
	TCHAR	return_string[100];
	short	ch_no;

	//-----------------------------
	// Get device name
	//-----------------------------
	m_DeviceName.GetWindowText(sz_device_name, _countof(sz_device_name));
	sprintf_s(device_name, "%S", sz_device_name);
	//-----------------------------
	// Initialization process, get device ID
	//-----------------------------
	ret	= DioInit(device_name, &dev_id);
	//-----------------------------
	// Error process
	//-----------------------------
	DioGetErrorString(ret, error_string);
	wsprintf(return_string, _T("Ret = %d : %S"), ret, error_string);
	m_Ret.SetWindowText(return_string);
	if (ret != DIO_ERR_SUCCESS){
		return;
	}
	//-----------------------------------
	// Get number of channels
	//-----------------------------------
	ret = DioGetMaxCountChannels(dev_id, &count_ch_num);
	if (ret != DIO_ERR_SUCCESS){
		//-----------------------------
		// Error process
		//-----------------------------
		DioGetErrorString(ret, error_string);
		wsprintf(return_string, _T("Ret = %d : %S"), ret, error_string);
		m_Ret.SetWindowText(return_string);
		return;
	}
	//-----------------------------------
	// Disable controls for channels not present in device
	//-----------------------------------
	for (ch_no = count_ch_num; ch_no < DISP_MAX_COUNT_CH; ch_no++){
		//-----------------------------------
		// Count edge control
		//-----------------------------------
		m_CountEdge[ch_no]->EnableWindow(false);
		//-----------------------------------
		// Comparison count value control
		//-----------------------------------
		m_CompareCountValue[ch_no]->EnableWindow(false);
		//-----------------------------------
		// Preset value control
		//-----------------------------------
		m_PresetValue[ch_no]->EnableWindow(false);
		//-----------------------------------
		// Count value control
		//-----------------------------------
		m_CountValue[ch_no]->EnableWindow(false);
		//-----------------------------------
		// Count value control
		//-----------------------------------
		m_CountStatus[ch_no]->EnableWindow(false);
	}
	//-----------------------------------
	// Correct the number of count channels to the maximum number of channels that can be displayed
	//-----------------------------------
	if(DISP_MAX_COUNT_CH < count_ch_num){
		count_ch_num = DISP_MAX_COUNT_CH;
	}
}

//=========================================================
// DioSetCountEdge()
//=========================================================
void CDiCounterDlg::OnBnClickedButtonDioSetCountEdge()
{
	long	ret;
	char	error_string[100];
	TCHAR	return_string[100];
	short	ch_no;
	short	ch_no_array[MAX_COUNT_CH];
	short	count_edge[MAX_COUNT_CH];
	TCHAR	cstr[100];

	//-----------------------------------
	// For each channel
	//-----------------------------------
	for(ch_no = 0; ch_no < count_ch_num; ch_no++){
		//-----------------------------------
		// Save channel number
		//-----------------------------------
		ch_no_array[ch_no]	= ch_no;
		//-----------------------------------
		// Get the specified count edge value
		//-----------------------------------
		m_CountEdge[ch_no]->GetLBText(m_CountEdge[ch_no]->GetCurSel(), cstr);
		if(wcscmp(cstr, _T("Rising")) == 0){
			count_edge[ch_no]	= DIO_COUNT_EDGE_UP;
		}else if(wcscmp(cstr, _T("Falling")) == 0){
			count_edge[ch_no]	= DIO_COUNT_EDGE_DOWN;
		}else{
			count_edge[ch_no]	= DIO_COUNT_EDGE_UP | DIO_COUNT_EDGE_DOWN;
		}
	}
	//-----------------------------
	// Set count edge
	//-----------------------------
	ret	= DioSetCountEdge(dev_id, ch_no_array, count_ch_num, count_edge);
	//-----------------------------
	// Error process
	//-----------------------------
	DioGetErrorString(ret, error_string);
	wsprintf(return_string, _T("Ret = %d : %S"), ret, error_string);
	m_Ret.SetWindowText(return_string);
}

//=========================================================
// DioSetCountMatchValue
//=========================================================
void CDiCounterDlg::OnBnClickedButtonDioSetCountMatchValue()
{
	long			ret;
	char			error_string[100];
	TCHAR			return_string[100];
	short			ch_no;
	short			ch_no_array[MAX_COUNT_CH];
	short			count_match_register_no[MAX_COUNT_CH];
	unsigned long	count_match_value[MAX_COUNT_CH];
	TCHAR			cstr[100];

	//-----------------------------------
	// For each channel
	//-----------------------------------
	for(ch_no = 0; ch_no < count_ch_num; ch_no++){
		//-----------------------------------
		// Save channel number
		//-----------------------------------
		ch_no_array[ch_no]				= ch_no;
		//-----------------------------------
		// Save comparison register number
		//-----------------------------------
		count_match_register_no[ch_no]	= 0;
		//-----------------------------------
		// Get the specified comparison count value
		//-----------------------------------
		m_CompareCountValue[ch_no]->GetWindowText(cstr, _countof(cstr));
		count_match_value[ch_no]		= wcstoul(cstr, NULL, 10);
	}
	//-----------------------------
	// Set comparison register
	//-----------------------------
	ret	= DioSetCountMatchValue(dev_id, ch_no_array, count_ch_num, count_match_register_no, count_match_value);
	//-----------------------------
	// Error process
	//-----------------------------
	DioGetErrorString(ret, error_string);
	wsprintf(return_string, _T("Ret = %d : %S"), ret, error_string);
	m_Ret.SetWindowText(return_string);
}

//=========================================================
// DioStartCount()
//=========================================================
void CDiCounterDlg::OnBnClickedButtonDioStartCount()
{
	long			ret;
	char			error_string[100];
	TCHAR			return_string[100];
	short			ch_no;
	short			ch_no_array[MAX_COUNT_CH];

	//-----------------------------------
	// For each channel
	//-----------------------------------
	for(ch_no = 0; ch_no < count_ch_num; ch_no++){
		//-----------------------------------
		// Save channel number
		//-----------------------------------
		ch_no_array[ch_no]	= ch_no;
	}
	//-----------------------------
	// Start count
	//-----------------------------
	ret	= DioStartCount(dev_id, ch_no_array, count_ch_num);
	//-----------------------------
	// Error process
	//-----------------------------
	DioGetErrorString(ret, error_string);
	wsprintf(return_string, _T("Ret = %d : %S"), ret, error_string);
	m_Ret.SetWindowText(return_string);
}

//=========================================================
// DioReadCount()
//=========================================================
void CDiCounterDlg::OnBnClickedButtonDioReadCount()
{
	long			ret;
	char			error_string[100];
	TCHAR			return_string[100];
	short			ch_no;
	short			ch_no_array[MAX_COUNT_CH];
	unsigned long	count[MAX_COUNT_CH];
	TCHAR			cstr[100];

	//-----------------------------------
	// For each channel
	//-----------------------------------
	for(ch_no = 0; ch_no < count_ch_num; ch_no++){
		//-----------------------------------
		// Save channel number
		//-----------------------------------
		ch_no_array[ch_no]	= ch_no;
	}
	//-----------------------------
	// Read count value
	//-----------------------------
	ret	= DioReadCount(dev_id, ch_no_array, count_ch_num, count);
	//-----------------------------
	// Error process
	//-----------------------------
	DioGetErrorString(ret, error_string);
	wsprintf(return_string, _T("Ret = %d : %S"), ret, error_string);
	m_Ret.SetWindowText(return_string);
	if(ret != DIO_ERR_SUCCESS){
		return;
	}
	//-----------------------------------
	// For each channel
	//-----------------------------------
	for(ch_no = 0; ch_no < count_ch_num; ch_no++){
		//-----------------------------
		// Update the display of count value
		//-----------------------------
		wsprintf(cstr, _T("%u"), count[ch_no]);
		m_CountValue[ch_no]->SetWindowText(cstr);
	}
}

//=========================================================
// DioGetCountStatus()
//=========================================================
void CDiCounterDlg::OnBnClickedButtonDioGetCountStatus()
{
	long			ret;
	char			error_string[100];
	TCHAR			return_string[100];
	short			ch_no;
	short			ch_no_array[MAX_COUNT_CH];
	unsigned long	count_status[MAX_COUNT_CH];
	TCHAR			cstr[100];

	//-----------------------------------
	// For each channel
	//-----------------------------------
	for(ch_no = 0; ch_no < count_ch_num; ch_no++){
		//-----------------------------------
		// Save channel number
		//-----------------------------------
		ch_no_array[ch_no]	= ch_no;
	}
	//-----------------------------
	// Read count status
	//-----------------------------
	ret	= DioGetCountStatus(dev_id, ch_no_array, count_ch_num, count_status);
	//-----------------------------
	// Error process
	//-----------------------------
	DioGetErrorString(ret, error_string);
	wsprintf(return_string, _T("Ret = %d : %S"), ret, error_string);
	m_Ret.SetWindowText(return_string);
	if(ret != DIO_ERR_SUCCESS){
		return;
	}
	//-----------------------------------
	// For each channel
	//-----------------------------------
	for(ch_no = 0; ch_no < count_ch_num; ch_no++){
		//-----------------------------
		// Update the display of count status
		//-----------------------------
		_itow_s(count_status[ch_no], cstr, 16);	
		m_CountStatus[ch_no]->SetWindowText(cstr);
	}
}

//=========================================================
// DioCountPreset()
//=========================================================
void CDiCounterDlg::OnBnClickedButtonDioCountPreset()
{
	long			ret;
	char			error_string[100];
	TCHAR			return_string[100];
	short			ch_no;
	short			ch_no_array[MAX_COUNT_CH];
	unsigned long	preset_count[MAX_COUNT_CH];
	TCHAR			cstr[100];

	//-----------------------------------
	// For each channel
	//-----------------------------------
	for(ch_no = 0; ch_no < count_ch_num; ch_no++){
		//-----------------------------------
		// Save channel number
		//-----------------------------------
		ch_no_array[ch_no]		= ch_no;
		//-----------------------------------
		// Get the specified preset count value
		//-----------------------------------
		m_PresetValue[ch_no]->GetWindowText(cstr, _countof(cstr));
		preset_count[ch_no]		= wcstoul(cstr, NULL, 10);
	}
	//-----------------------------
	// Preset count value
	//-----------------------------
	ret	= DioCountPreset(dev_id, ch_no_array, count_ch_num, preset_count);
	//-----------------------------
	// Error process
	//-----------------------------
	DioGetErrorString(ret, error_string);
	wsprintf(return_string, _T("Ret = %d : %S"), ret, error_string);
	m_Ret.SetWindowText(return_string);
}

//=========================================================
// DioStopCount()
//=========================================================
void CDiCounterDlg::OnBnClickedButtonDioStopCount()
{
	long			ret;
	char			error_string[100];
	TCHAR			return_string[100];
	short			ch_no;
	short			ch_no_array[MAX_COUNT_CH];

	//-----------------------------------
	// For each channel
	//-----------------------------------
	for(ch_no = 0; ch_no < count_ch_num; ch_no++){
		//-----------------------------------
		// Save channel number
		//-----------------------------------
		ch_no_array[ch_no]	= ch_no;
	}
	//-----------------------------
	// Stop count
	//-----------------------------
	ret	= DioStopCount(dev_id, ch_no_array, count_ch_num);
	//-----------------------------
	// Error process
	//-----------------------------
	DioGetErrorString(ret, error_string);
	wsprintf(return_string, _T("Ret = %d : %S"), ret, error_string);
	m_Ret.SetWindowText(return_string);
}

//=========================================================
// DioExit()
//=========================================================
void CDiCounterDlg::OnBnClickedButtonDioExit()
{
	long	ret;
	char	error_string[100];
	TCHAR	return_string[100];

	//-----------------------------
	// Exit process
	//-----------------------------
	ret	= DioExit(dev_id);
	//-----------------------------
	// Error process
	//-----------------------------
	DioGetErrorString(ret, error_string);
	wsprintf(return_string, _T("Ret = %d : %S"), ret, error_string);
	m_Ret.SetWindowText(return_string);
}

//=========================================================
// Application end
//=========================================================
void CDiCounterDlg::OnBnClickedButtonExit()
{
	//-----------------------------
	// Close the dialog
	//-----------------------------
	CDialog::OnOK();
}
