// DLG_WarningSetup.cpp: 实现文件
//

#include "stdafx.h"
#include "SmsManager.h"
#include "DLG_WarningSetup.h"
#include "afxdialogex.h"


// DLG_WarningSetup 对话框

IMPLEMENT_DYNAMIC(DLG_WarningSetup, CDialogEx)

DLG_WarningSetup::DLG_WarningSetup(CWnd* pParent /*=nullptr*/)
	: CDialogEx(IDD_WARNINGSETUP, pParent)
{
	memset(&m_Setup, 0, sizeof(m_Setup));
}

DLG_WarningSetup::~DLG_WarningSetup()
{
}

void DLG_WarningSetup::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);

	DDX_Check(pDX, IDC_WARNINGSETUP_ENABLE, m_bEnable);
	DDX_Check(pDX, IDC_WARNINGSETUP_SOUND, m_bSound);
	DDX_Check(pDX, IDC_WARNINGSETUP_FLASH, m_bFlash);
	DDX_Check(pDX, IDC_WARNINGSETUP_WINDOW, m_bWindow);
	DDX_Text(pDX, IDC_WARNINGSETUP_TIMER, m_lTimer);
	DDX_Check(pDX, IDC_WARNINGSETUP_ONLYCONTENT, m_bOnlyContent);
	DDX_Check(pDX, IDC_WARNINGSETUP_TIMEOUT, m_bTimeout);
	DDV_MinMaxUInt(pDX, m_lTimer, 1, 100);
}


BEGIN_MESSAGE_MAP(DLG_WarningSetup, CDialogEx)
	ON_BN_CLICKED(IDOK, &DLG_WarningSetup::OnBnClickedOk)
END_MESSAGE_MAP()


// DLG_WarningSetup 消息处理程序


void DLG_WarningSetup::OnBnClickedOk()
{
	if (!UpdateData(true))
		return;

	if (m_lTimer <= 0 || m_lTimer > 100)
	{
		MessageBox(_T("审核提醒间隔时间有误,请检查"), _T("提醒"), MB_ICONINFORMATION);
		GetDlgItem(IDC_WARNINGSETUP_TIMER)->SetFocus();
	}

	m_Setup.Warning_Enable = m_bEnable;
	m_Setup.Warning_Timer = m_lTimer;
	m_Setup.Warning_Sound = m_bSound;
	m_Setup.Warning_Flash = m_bFlash;
	m_Setup.Warning_Window = m_bWindow;

	m_Setup.Warning_OnlyContent = m_bOnlyContent;
	m_Setup.Warning_Timeout     = m_bTimeout;
	CDialogEx::OnOK();
}

void DLG_WarningSetup::SetSetup(SM_Setup setup)
{
	m_Setup = setup;
}
SM_Setup DLG_WarningSetup::GetSetup()
{
	return m_Setup;
}

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

	m_bEnable = m_Setup.Warning_Enable;
	m_lTimer = m_Setup.Warning_Timer;
	m_bSound = m_Setup.Warning_Sound;
	m_bFlash = m_Setup.Warning_Flash;
	m_bWindow = m_Setup.Warning_Window;

	m_bOnlyContent = m_Setup.Warning_OnlyContent;
	m_bTimeout = m_Setup.Warning_Timeout;

	if (m_lTimer <= 0 || m_lTimer > 100)
		m_lTimer = 8;
	UpdateData(false);

	return TRUE;  // return TRUE unless you set the focus to a control
				  // 异常: OCX 属性页应返回 FALSE
}