// DlgSelectHistoryMoveOperation.cpp : _xZkqqHx_iDeDiDjDiDhGiDiKiDiBiDjDiDgFiBfLiDfGiDiHiDjD_xHqqkZx_ _xZkqqHx_iDhEiDeAiDeDiDiL_xHqqkZx_
//

#include "stdafx.h"
#include <algorithm>				// For find template.
#include "DynamicDraw.h"
#include "UtilErr.h"				// For FFMessageBox.
#include "UtilDlg.h"				// For SetUnitString.etc.
//#include "UtilStr.h"				// For GetResString.
//#include "UtilMath.h"				// For _i64towcs.
#include "UtilWin.h"				// For FFGetWindowText.
#include "RegData.h"				// For g_pReg.
#include "FrameWnd.h"				// For FFGetMainWnd().
#include "HiFrameWnd.h"				// For FFGetHiMainWnd().
#include "DlgHistoryMoveOpeList.h"	// For CFCDlgHistoryMoveOpeList.
#include "DlgSelectHistoryMoveOperation.h"	// This header.

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CFCDlgSelectHistoryMoveOperation _xZkqqHx_iDiGiBfLiDfFiKnGjAjEiBeC_xHqqkZx_

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	CFCDlgSelectHistoryMoveOperation::UpdateOpeListBox
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_jBiAiNoMjFpLjGeAiIoKjHjHiCmMiDiKiDfIiDgHiDhLiDgCiDeOiDfIiCpAiBeBjFmPjAjEiCmMjCgMiCmJiKoOiCmDiCkCiCmEiNfIjAfGiClHiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	05.10.07 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
void CFCDlgSelectHistoryMoveOperation::UpdateOpeListBox ()
{
	// _xZkqqHx_iDiMiDfHiDfIiDgHiDiKiCkJiCoHjBiAiNoMjFpLjGeAiIoKjHjHiCpAiOoGjDlOiBeC_xHqqkZx_
	vector<longPair> vIdAndValue;
	CFCDlgHistoryMoveOpeList::GetHiMoveOpeList(vIdAndValue);
	// _xZkqqHx_jBiAiNoMjFpLjGeAiDfOiDeDiDgHiDiLiIoKjHjHiCpAiOoGjDlOiBeC_xHqqkZx_
	WStringVector vTitle;
	CFCDlgHistoryMoveOpeList::HiMoveOpeListToTitle(vTitle, vIdAndValue);
	// _xZkqqHx_iDiKiDfIiDgHiDhLiDgCiDeOiDfIiCmJjBiAiNoMjFpLjGeAiDfOiDeDiDgHiDiLiIoKjHjHiCpAjAnNjCoIiBeC_xHqqkZx_
	CListBox* pListBox = (CListBox*)GetDlgItem(IDC_SMO_LST_OPE_LIST);
	pListBox->ResetContent();
	WStringVector::const_iterator iTt;
	for (iTt = vTitle.begin(); iTt != vTitle.end(); iTt++)
		pListBox->AddString(WStrToTStr(*iTt));

	// _xZkqqHx_iMlLiNnNjBeJjBpAiClDiCoKiCmEiCkCiCoJiInKjDkOjFpLjGeAiCpAiMjPiNpFiBeC_xHqqkZx_
	vector<longPair>::const_iterator iTv = std::find(	vIdAndValue.begin(),
														vIdAndValue.end(),
														longPair(m_lHiMoveOpeType, m_lHiMoveOpeValue));
	if (iTv != vIdAndValue.end())
	//----- _xZkqqHx_iMlLiNnNjBeJjBpAiClDiCoKiCmEiCkCiCoJjFpLjGeAiCkKiIoKjHjHiCmJjBlGiNnNiClHiCoJiPoKiNiH_xHqqkZx_ -----
	{
		// _xZkqqHx_iDiKiDfIiDgHiDhLiDgCiDeOiDfIiCmMiMlLiNnNjCgMiCpAjAnNjCoIiBeC_xHqqkZx_
		pListBox->SetCurSel(int(iTv - vIdAndValue.begin()));
	} else
	//----- _xZkqqHx_iMlLiNnNjBeJjBpAiClDiCoKiCmEiCkCiCoJjFpLjGeAiCkKiIoKjHjHiCmJjBlGiNnNiClFiCmIiCkCiPoKiNiH_xHqqkZx_ -----
	{
		// _xZkqqHx_iDiKiDfIiDgHiDhLiDgCiDeOiDfIiCmMiMlLiNnNjCgMiCpAjAnNjCoIiBeC_xHqqkZx_
		pListBox->SetCurSel(0);
		m_lHiMoveOpeType = vIdAndValue[0].first;
		m_lHiMoveOpeValue = vIdAndValue[0].second;
	}
} // CFCDlgSelectHistoryMoveOperation::UpdateOpeListBox.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	CFCDlgSelectHistoryMoveOperation::UpdateActivate
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	OK_xZkqqHx_iDhLiDfOiDjDjDjJiCmMiDeBiDeOiDgFiDeCiDhFiPpDjBnEiCpAjAnNjCoIiClHiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	05.10.08 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
void CFCDlgSelectHistoryMoveOperation::UpdateActivate ()
{
	long lHiMoveOpeType;
	long lHiMoveOpeValue;
	// _xZkqqHx_iMlLiNnNjBeJjBpAiClDiCoKiCmEiCkCiCoJiInKjDkOjFpLjGeAiCpAiOoGjDlOiBeC_xHqqkZx_
	lHiMoveOpeType = FFGetHiMainWnd()->GetHiMoveOperation(lHiMoveOpeValue);
	// OK_xZkqqHx_iDhLiDfOiDjDiCmMiPpDjBnEiCpAjAnNjCoIiBeC_xHqqkZx_
	GetDlgItem(IDOK)->EnableWindow(	lHiMoveOpeType != m_lHiMoveOpeType ||
									lHiMoveOpeValue != m_lHiMoveOpeValue);
} // CFCDlgSelectHistoryMoveOperation::UpdateActivate.

/////////////////////////////////////////////////////////////////////////////
// CFCDlgSelectHistoryMoveOperation _xZkqqHx_iDfPiDeDiDeBiDiNiDeP_xHqqkZx_

CFCDlgSelectHistoryMoveOperation::CFCDlgSelectHistoryMoveOperation(CWnd* pParent /*=NULL*/)
	: BASE_CLASS(CFCDlgSelectHistoryMoveOperation::IDD, pParent)
{
	//{{AFX_DATA_INIT(CFCDlgSelectHistoryMoveOperation)
		// _xZkqqHx_iDiBiDiC_xHqqkZx_ - ClassWizard _xZkqqHx_iCmNiClBiCmMiImKjChFiCmJiDhNiDgCiDhDiDjDiDePjHhAiCmMiDhNiDeOiDiNiCpAjCmHiJmBiCnMiClNiCmNiNoNiPjMiClFiCnMiClHiBeC_xHqqkZx_
	//}}AFX_DATA_INIT
}

void CFCDlgSelectHistoryMoveOperation::DoDataExchange(CDataExchange* pDX)
{
	BASE_CLASS::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CFCDlgSelectHistoryMoveOperation)
		// _xZkqqHx_iDiBiDiC_xHqqkZx_ - ClassWizard _xZkqqHx_iCmNiClBiCmMiImKjChFiCmJiDhNiDgCiDhDiDjDiDePjHhAiCmMiDhNiDeOiDiNiCpAjCmHiJmBiCnMiClNiCmNiNoNiPjMiClFiCnMiClHiBeC_xHqqkZx_
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CFCDlgSelectHistoryMoveOperation, BASE_CLASS)
	//{{AFX_MSG_MAP(CFCDlgSelectHistoryMoveOperation)
	ON_LBN_DBLCLK(IDC_SMO_LST_OPE_LIST, OnDblclkSmoLstOpeList)
	ON_LBN_SELCHANGE(IDC_SMO_LST_OPE_LIST, OnSelchangeSmoLstOpeList)
	ON_BN_CLICKED(IDC_SMO_BTN_EDIT_OPE_LIST, OnSmoBtnEditOpeList)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CFCDlgSelectHistoryMoveOperation _xZkqqHx_iDiBiDgCiDfKiBfLiDfH_xHqqkZx_ _xZkqqHx_iDgOiDjDiDgIiDiJ_xHqqkZx_

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	CFCDlgSelectHistoryMoveOperation::OnInitDialog
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDfPiDeDiDeBiDiNiDePjFfMiOkGiOjOiCmJiOmAiNhDiClDiCoKiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jFnEjCgM_xHqqkZx_>	_xZkqqHx_iDhHiDiLiDhGiOfBiPmGiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	05.10.08 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
BOOL CFCDlgSelectHistoryMoveOperation::OnInitDialog ()
{
	// Baseclass_xZkqqHx_iKnGjAjEiOmAiNhDiBeC_xHqqkZx_
	BASE_CLASS::OnInitDialog();
	// _xZkqqHx_iMlLiNnNjBeJjBpAiClDiCoKiCmEiCkCiCoJiInKjDkOjFpLjGeAiCpAiOoGjDlOiBeC_xHqqkZx_
	m_lHiMoveOpeType = FFGetHiMainWnd()->GetHiMoveOperation(m_lHiMoveOpeValue);
	// _xZkqqHx_iDiKiDfIiDgHiDhLiDgCiDeOiDfIiCpAiPiJiKpKiJlLiBeC_xHqqkZx_
	UpdateOpeListBox();
	// OK_xZkqqHx_iDhLiDfOiDjDjDjJiCmMiDeBiDeOiDgFiDeCiDhFiPpDjBnEiCpAjAnNjCoIiClHiCoJiBeC_xHqqkZx_
	UpdateActivate();

	// _xZkqqHx_iDfPiDeDiDeBiDiNiDePiCmMjCfAiImKjFfMiOkGiCpAjAnNjCoIiClHiCoJiBeC_xHqqkZx_
	::SetUnitString(m_hWnd);
	// _xZkqqHx_jHjIiCkLjIhCjBmOiJjOjFlGiOjKjHpBiCmMjAnNjCoIiCpAiNhDiCkEiBeC_xHqqkZx_
	::RightByLeftHand(m_hWnd);
	// _xZkqqHx_iDfPiDeDiDeBiDiNiDePiCpAiDhNiDeFiDfIiImKjChFiCmJiInKjDkOiBeC_xHqqkZx_
	if (!IsKindOf(RUNTIME_CLASS(CPropertyPage)))
		::FFJustifyWindow(m_hWnd);
	return TRUE;  // _xZkqqHx_iDfCiDjDiDgHiDiNiBfLiDiLiCmJiDhEiDeIiBfLiDeKiDfIiCpAjAnNjCoIiClFiCmIiCkCiCmGiCkLiBeBjGnPiCoIjCgMiCmN_xHqqkZx_ TRUE _xZkqqHx_iCmGiCmIiCoIiCnMiClH_xHqqkZx_
	              // _xZkqqHx_jHoBiKeP_xHqqkZx_: OCX _xZkqqHx_iDhGiDiNiDhAiDgFiDeC_xHqqkZx_ _xZkqqHx_iDhJiBfLiDfHiCmMjGnPiCoIjCgMiCmN_xHqqkZx_ FALSE _xZkqqHx_iCmGiCmIiCoIiCnMiClH_xHqqkZx_
} // CFCDlgSelectHistoryMoveOperation::OnInitDialog.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	CFCDlgSelectHistoryMoveOperation::OnOK
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	OK_xZkqqHx_iDhLiDfOiDjDiCkJiCoHiOmAiNhDiClDiCoKiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	05.10.08 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
void CFCDlgSelectHistoryMoveOperation::OnOK ()
{
	// _xZkqqHx_iMlLiNnNiCmMiDfCiDjDiDhLiDhLiDgCiDeOiDfIjAnNjCoIiCpAjCmKjCgNiBeC_xHqqkZx_
	FFGetMainWnd()->PostMessage(WM_USER_SET_HI_MOVE_OPERATION,
								(WPARAM)m_lHiMoveOpeType,
								(LPARAM)m_lHiMoveOpeValue);
	// Baseclass_xZkqqHx_iKnGjAjEiOmAiNhDiBeC_xHqqkZx_
	BASE_CLASS::OnOK();
} // CFCDlgSelectHistoryMoveOperation::OnOK.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	CFCDlgSelectHistoryMoveOperation::OnSelchangeSmoLstOpeList
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iInKjDkOjFpLjGeAiIoKjHjHiCmMiDiKiDfIiDgHiDhLiDgCiDeOiDfIiCmMjBeJjBpAiCkKjFmPiNfIiClDiCoKiClNiCmGiCkLiCmJiOmAiNhDiClDiCoKiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	05.10.08 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
void CFCDlgSelectHistoryMoveOperation::OnSelchangeSmoLstOpeList ()
{
	// _xZkqqHx_iDiMiDfHiDfIiDgHiDiKiCkJiCoHjBiAiNoMjFpLjGeAiIoKjHjHiCpAiOoGjDlOiBeC_xHqqkZx_
	vector<longPair> vIdAndValue;
	CFCDlgHistoryMoveOpeList::GetHiMoveOpeList(vIdAndValue);
	// _xZkqqHx_iDiKiDfIiDgHiDhLiDgCiDeOiDfIiCpAiOoGjDlOiBeC_xHqqkZx_
	CListBox* pListBox = (CListBox*)GetDlgItem(IDC_SMO_LST_OPE_LIST);
	m_lHiMoveOpeType = vIdAndValue[pListBox->GetCurSel()].first;
	m_lHiMoveOpeValue = vIdAndValue[pListBox->GetCurSel()].second;
	// OK_xZkqqHx_iDhLiDfOiDjDjDjJiCmMiDeBiDeOiDgFiDeCiDhFiPpDjBnEiCpAjAnNjCoIiClHiCoJiBeC_xHqqkZx_
	UpdateActivate();
} // CFCDlgSelectHistoryMoveOperation::OnSelchangeSmoLstOpeList.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	CFCDlgSelectHistoryMoveOperation::OnDblclkSmoLstOpeList
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iInKjDkOjFpLjGeAiIoKjHjHiCmMiDiKiDfIiDgHiDhLiDgCiDeOiDfIiCpAiDfPiDhFiDiLiDeOiDiKiDgCiDeOiClFiClNiCmGiCkLiOmAiNhDiClDiCoKiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	05.10.08 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
void CFCDlgSelectHistoryMoveOperation::OnDblclkSmoLstOpeList ()
{
	PostMessage(WM_COMMAND, IDOK, 0);
} // CFCDlgSelectHistoryMoveOperation::OnDblclkSmoLstOpeList.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	CFCDlgSelectHistoryMoveOperation::OnSmoBtnEditOpeList
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDhLiDfOiDjDiBhFjHjKjHpAiInKjDkOjFpLjGeAiIoKjHjHiCmMjFnCiPfHiBhGiCkJiCoHiOmAiNhDiClDiCoKiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	05.10.08 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
void CFCDlgSelectHistoryMoveOperation::OnSmoBtnEditOpeList ()
{
	// _xZkqqHx_iDfPiDeDiDeBiDiNiDePiCpAjFfMiOkGiClDiClJiCoJiBeC_xHqqkZx_
	FFGetMainWnd()->SendMessage(WM_COMMAND, ID_OPTION_HISTORY_MOVE_OPE_LIST, 0);
	// _xZkqqHx_iDiKiDfIiDgHiDhLiDgCiDeOiDfIiCpAiPiJiKpKiJlLiBeC_xHqqkZx_
	UpdateOpeListBox();
	// OK_xZkqqHx_iDhLiDfOiDjDjDjJiCmMiDeBiDeOiDgFiDeCiDhFiPpDjBnEiCpAjAnNjCoIiClHiCoJiBeC_xHqqkZx_
	UpdateActivate();
//----- 05.10.08 Fukushiro M. _xZkqqHx_iNoNiPjMiOgO_xHqqkZx_ ()-----
//
//	CFCDlgHistoryMoveOpeList dlg;
//	if (dlg.DoModal() == IDOK)
//	{
//		// _xZkqqHx_iDiKiDfIiDgHiDhLiDgCiDeOiDfIiCpAiPiJiKpKiJlLiBeC_xHqqkZx_
//		UpdateOpeListBox();
//		// OK_xZkqqHx_iDhLiDfOiDjDjDjJiCmMiDeBiDeOiDgFiDeCiDhFiPpDjBnEiCpAjAnNjCoIiClHiCoJiBeC_xHqqkZx_
//		UpdateActivate();
//	}
//----- 05.10.08 Fukushiro M. _xZkqqHx_iNoNiPjMiPeJ_xHqqkZx_ ()-----
} // CFCDlgSelectHistoryMoveOperation::OnSmoBtnEditOpeList.
