// EnterSomething.cpp : 구현 파일입니다.
//

#include "stdafx.h"
#include "ConsoleTransfer.h"
#include "EnterSomethingDlg.h"


// CEnterSomethingDlgDlg 대화 상자입니다.

IMPLEMENT_DYNAMIC(CEnterSomethingDlg, CDialog)
/*
CEnterSomethingDlg::CEnterSomethingDlg(CWnd* pParent /*=NULL*./)
	: CDialog(CEnterSomethingDlg::IDD, pParent)
{
}
*/
CEnterSomethingDlg::CEnterSomethingDlg(UINT nID, UINT nTextID, TCHAR password, CWnd* pParent)
	: CDialog(CEnterSomethingDlg::IDD, pParent)
{
	m_String = _T("");

	m_Title.LoadString(nID);
	m_Text.LoadString(nTextID);
	m_passChar = password;
	m_nPreselectMin=-1;
	m_nPreselectMax=-1;
}

CEnterSomethingDlg::CEnterSomethingDlg(UINT nID, LPCSTR pText, TCHAR password, CWnd* pParent)
	: CDialog(CEnterSomethingDlg::IDD, pParent)
{
	m_String = _T("");

	m_Title.LoadString(nID);
	m_Text = pText;
	m_passChar = password;
	m_nPreselectMin=-1;
	m_nPreselectMax=-1;
}

CEnterSomethingDlg::~CEnterSomethingDlg()
{
}

void CEnterSomethingDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_EDIT, m_EditCtrl);
	DDX_Control(pDX, IDOK, m_OkCtrl);
	DDX_Text(pDX, IDC_EDIT, m_String);
}


BEGIN_MESSAGE_MAP(CEnterSomethingDlg, CDialog)
	ON_EN_CHANGE(IDC_EDIT, OnChangeEdit)
END_MESSAGE_MAP()


// CEnterSomethingDlg 메시지 처리기입니다.

BOOL CEnterSomethingDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	SetWindowText(m_Title);
	
	//Disable the OK button if the edit field is empty
	m_OkCtrl.EnableWindow(m_String!=""?TRUE:FALSE);

	m_EditCtrl.SetPasswordChar(m_passChar);
	
	GetDlgItem(IDC_TEXT)->SetWindowText(m_Text);
	if (m_nPreselectMin!=-1)
	{
		m_EditCtrl.SetSel(m_nPreselectMin,m_nPreselectMax);
		return FALSE;
	}

	m_EditCtrl.SetFocus();

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX-Eigenschaftenseiten sollten FALSE zur?kgeben
}

void CEnterSomethingDlg::OnOK() 
{
	UpdateData(TRUE);

	if (m_String == "") {
		AfxMessageBox("문자를 입력하십시오.", MB_ICONEXCLAMATION);
	}

	CDialog::OnOK();
}

void CEnterSomethingDlg::OnChangeEdit() 
{
	//Disable the OK button if the edit field is empty
	UpdateData(TRUE);
	m_OkCtrl.EnableWindow(m_String!=""?TRUE:FALSE);
}
