// DlgCommonEditorModify.cpp : _xZkqqHx_iDeDiDjDiDhGiDiKiDiBiDjDiDgFiBfLiDfGiDiHiDjD_xHqqkZx_ _xZkqqHx_iDhEiDeAiDeDiDiL_xHqqkZx_
//

#include "stdafx.h"
#include "DynamicDraw.h"
#include "ObjIDTbl.h"				// For FCObjIDTbl.
#include "Env.h"					// For FCEnv.
#include "FoundDoc.h"				// For g_pDoc.
#include "ObjDynabase.h"				// For FCObjDynabase.
#include "ZOrder.h"					// For FCZOrder.
#include "SheetManager.h"			// For FCSheetManager.
#include "UtilDlg.h"				// For SetUnitString.etc.
#include "UtilWin.h"				// For ExecMolipDraw.etc.
#include "UtilErr.h"				// For FFMessageBox.
#include "Communicate.h"			// For SendData.
#include "DlgCommonEditorModify.h"	// This header.

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

/////////////////////////////////////////////////////////////////////////////
// CFCDlgCommonEditorModify _xZkqqHx_iDfPiDeDiDeBiDiNiDeP_xHqqkZx_

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	CFCDlgCommonEditorModify::CFCDlgCommonEditorModify
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDfCiDjDiDfIiDgHiDiJiDeOiDfOiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	01.04.08 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
CFCDlgCommonEditorModify::CFCDlgCommonEditorModify (CWnd* pParent /*=NULL*/)
	: BASE_CLASS(CFCDlgCommonEditorModify::IDD, pParent)
{
	//{{AFX_DATA_INIT(CFCDlgCommonEditorModify)
		// _xZkqqHx_iDiBiDiC_xHqqkZx_ - ClassWizard _xZkqqHx_iCmNiClBiCmMiImKjChFiCmJiDhNiDgCiDhDiDjDiDePjHhAiCmMiDhNiDeOiDiNiCpAjCmHiJmBiCnMiClNiCmNiNoNiPjMiClFiCnMiClHiBeC_xHqqkZx_
	//}}AFX_DATA_INIT

	//----- _xZkqqHx_iDiGiBfLiDfFjFmPjAjEiPiJiKpKiJlL_xHqqkZx_ -----
	m_iRecModified = 0;	// 0:_xZkqqHx_jGkCiPeDjAlDiBeB_xHqqkZx_1:_xZkqqHx_iPeDjAlDjCiGiBeB_xHqqkZx_2:_xZkqqHx_iOpDjAeNjCiGiBeB_xHqqkZx_3:_xZkqqHx_iOpDjAeNiNmPiCnNiBeC_xHqqkZx_
} // CFCDlgCommonEditorModify::CFCDlgCommonEditorModify.

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

/////////////////////////////////////////////////////////////////////////////
// CFCDlgCommonEditorModify _xZkqqHx_iDiGiBfLiDfFiKnGjAjEiBeC_xHqqkZx_

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	CFCDlgCommonEditorModify::ExecEditdraw
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDeHiDgGiDeCiDgCiDgHiDgIiDiNiBfLiCpAiLeOjDkOiClFiBeBiOhHjCoIiClDiCoKiClNiDgGiBfLiDfOiCpAjBjHjAeNiClHiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	lDataSize	:_xZkqqHx_jBjHjAeNiClHiCoJiDgGiBfLiDfOiCmMiDfEiDeDiDfJiCpAiOhHjCoIiBeC_xHqqkZx_
 *			pData		:_xZkqqHx_jBjHjAeNiClHiCoJiDgGiBfLiDfOiCpAiOhHjCoIiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jFnEjCgM_xHqqkZx_>	_xZkqqHx_iLeOjDkOiBjFjBjHjAeNiCmJjAkMiMpHiClFiClNiPoKiNiHiCmN_xHqqkZx_ TRUE_xZkqqHx_iBeBiOlIjEhDiClFiClNiPoKiNiHiCmN_xHqqkZx_ FALSE_xZkqqHx_iCpAjFnEiClHiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	01.04.08 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
BOOL CFCDlgCommonEditorModify::ExecEditdraw (long lDataSize, const BYTE* pData)
{
	// _xZkqqHx_iLeOjDkOiDhAiDiJiDiBiBfLiDfOiCmMjFlGiOjKjHpBiCpAiNoMiCoJiBeC_xHqqkZx_
	WString strParam;
// 01.07.23 Fukushiro M. 1_xZkqqHx_iNhDjFmPiNfI_xHqqkZx_ ()
//	strParam.Format(_T("-%s -hwnd %x"), GetEditdrawCommand(), (unsigned long)m_hWnd);
	strParam.Format(L"-%s -hwnd:%x", GetEditdrawCommand(), (unsigned long)m_hWnd);
	DWORD dwThreadId;
	// _xZkqqHx_iPeJjHlJiKmEiOiLjFhEiCkLiCmF_xHqqkZx_ _xZkqqHx_iDeHiDgGiDeCiDgCiDgHiDgIiDiNiBfLiCpAiLeOjDkOiBeC_xHqqkZx_
	if (!::ExecMolipDraw(strParam, m_hWnd,
						WM_USER_EDITDRAW_QUITED, &dwThreadId))
		return FALSE;
	// _xZkqqHx_iDiMiDfCiBfLiDgIiPeDjAlDiCpAjAnNjCoIiBeC_xHqqkZx_
	m_iRecModified = 1;	// 0:_xZkqqHx_jGkCiPeDjAlDiBeB_xHqqkZx_1:_xZkqqHx_iPeDjAlDjCiGiBeB_xHqqkZx_2:_xZkqqHx_iOpDjAeNjCiGiBeB_xHqqkZx_3:_xZkqqHx_iOpDjAeNiNmPiCnNiBeC_xHqqkZx_
	// _xZkqqHx_iDeHiDgGiDeCiDgCiDgHiDgIiDiNiBfLiCmMiDiBiDeDiDjDiDhEiDiMiBfLiDiAiDeFiDeCiDjDiDgIiDeFiDgOiDjDiDgIiDiLiCpAiOoGjDlOiBeC_xHqqkZx_
	m_hwndEditdraw = ::GetThreadTopWnd(dwThreadId);
	// _xZkqqHx_iDeHiDgGiDeCiDgCiDgHiDgIiDiNiBfLiCnGiBeBiDgGiBfLiDfOiCmMiOpDjAeNiCpAiOhHiOkGiBeC_xHqqkZx_
	::PostMessage(m_hwndEditdraw, WM_USER_TO_EDITDRAW, FDTC_RECEIVE_STREAM,
					reinterpret_cast<LPARAM>(m_hWnd));
	// _xZkqqHx_iDeHiDgGiDeCiDgCiDgHiDgIiDiNiBfLiCnGiLpDiCmMjGlMjBePiCmGiDgGiBfLiDfOiCpAjDfNjBjHiBeC_xHqqkZx_
	if (!::SendData(m_hwndEditdraw, lDataSize, pData))
	{
		// IDS_ERR_MSG_FAIL_COMMUNICATE = "_xZkqqHx_iDgGiBfLiDfOjBjHiOpDjAeNiCmJiOlIjEhDiClFiCnMiClFiClN_xHqqkZx_"
		FFErrorBox(IDS_ERR_MSG_FAIL_COMMUNICATE);
		// _xZkqqHx_iDeHiDgGiDeCiDgCiDgHiDgIiDiNiBfLiCnGiDeBiDhGiDiKiPeJjHlJjGlNjHnPiBeC_xHqqkZx_
		::PostMessage(m_hwndEditdraw, WM_USER_TO_EDITDRAW, FDTC_APP_CLOSE, 0);
		// _xZkqqHx_iDiMiDfCiBfLiDgIiPeDjAlDiCpAjAnNjCoIiBeC_xHqqkZx_
		m_iRecModified = 0;	// 0:_xZkqqHx_jGkCiPeDjAlDiBeB_xHqqkZx_1:_xZkqqHx_iPeDjAlDjCiGiBeB_xHqqkZx_2:_xZkqqHx_iOpDjAeNjCiGiBeB_xHqqkZx_3:_xZkqqHx_iOpDjAeNiNmPiCnNiBeC_xHqqkZx_
		return FALSE;
	}
	return TRUE;
} // CFCDlgCommonEditorModify::ExecEditdraw.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	CFCDlgCommonEditorModify::OnReceiveEditdrawStream
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDeHiDgGiDeCiDgCiDgHiDgIiDiNiBfLiCkJiCoHjBjHjAeNiClDiCoKiCoJiDfIiDgHiDiKiBfLiDiAiDgGiBfLiDfOiCpAiOpDjAeNiClFiBeB_xHqqkZx_
 *			_xZkqqHx_iDfOiBfLiDfBiDgCiDgHiCmMiDiMiDfCiBfLiDgIiCpAjAnNjCoIiClHiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	hwndChipEdit	:_xZkqqHx_jBjHjAeNiMlDiCmMiDeHiDgGiDeCiDgCiDgHiDgIiDiNiBfLiCmMiDhEiDiMiBfLiDiAiDeFiDeCiDjDiDgIiDeFiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iJpAjAoA_xHqqkZx_>	CFCMainFrame_xZkqqHx_iCkJiCoHiOmAiNhDiClDiCoKiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	01.04.08 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
void CFCDlgCommonEditorModify::OnReceiveEditdrawStream (HWND hwndChipEdit)
{
	// _xZkqqHx_iDiMiDfCiBfLiDgIiPeDjAlDiCpAjAnNjCoIiBeC_xHqqkZx_
	m_iRecModified = 2;	// 0:_xZkqqHx_jGkCiPeDjAlDiBeB_xHqqkZx_1:_xZkqqHx_iPeDjAlDjCiGiBeB_xHqqkZx_2:_xZkqqHx_iOpDjAeNjCiGiBeB_xHqqkZx_3:_xZkqqHx_iOpDjAeNiNmPiCnNiBeC_xHqqkZx_

	BYTE* bypData;
	long  lDataSize;
	// _xZkqqHx_iDfIiDgHiDiKiBfLiDiAiCmMiOpDjAeNiBeC_xHqqkZx_
	if (!::ReceiveData(hwndChipEdit, lDataSize, bypData))
	{
		// IDS_ERR_MSG_FAIL_COMMUNICATE = "_xZkqqHx_iDgGiBfLiDfOjBjHiOpDjAeNiCmJiOlIjEhDiClFiCnMiClFiClN_xHqqkZx_"
		FFErrorBox(IDS_ERR_MSG_FAIL_COMMUNICATE);
		return;
	}
	/*-------------------- _xZkqqHx_iDiMiDfCiBfLiDgIiNoMjAkM_xHqqkZx_ ----------------------------
		_xZkqqHx_iKpJiCmJjFjEjFgJiCkKjDgPjIfOiClDiCoKiCmEiCkCiCoJiOjOiCmNiBeBjFjEjFgJiCmMjCmHiJmBiPiIjHjNiCpAiNhDiCkEiBeC_xHqqkZx_
		_xZkqqHx_jFjEjFgJ_xHqqkZx_ID_xZkqqHx_iCkKiPgEjFkBiClHiCoJiCmMiCpAjEpAiCkPiCoJiClNiCnPiCmJiBeB_xHqqkZx_
		_xZkqqHx_iHeA_xHqqkZx_ _xZkqqHx_iIoKiOjOjDeJiCmIiDgFiBfLiDhFiDiLiCmJjFjEjFgJiCpAjDgPjIfOiClHiCoJiBeC_xHqqkZx_
		_xZkqqHx_iHeB_xHqqkZx_ _xZkqqHx_jFjEjFgJiCmM_xHqqkZx_ID->_xZkqqHx_jFjEjFgJiDhMiDeDiDjDiDfOjFmPiKlHiPiIjHjNiCpAiNhDiCkEiBeC_xHqqkZx_
		_xZkqqHx_iHeC_xHqqkZx_ _xZkqqHx_iKpJjBlGiCmMiDgFiBfLiDhFiDiLiCpAjFjMiLeBiClFiBeBiIoKiOjOjDeJiCmIiDgFiBfLiDhFiDiLiCmMjFjEjFgJiCpAiIoKiCmCiClIiCmC_xHqqkZx_
		   _xZkqqHx_iKpJjBlGiCmMiDgFiBfLiDhFiDiLiCmJjDgPjIfOiClFiCmEiCoEiCkNiBeC_xHqqkZx_
	------------------------------------------------------------------*/
	//----- _xZkqqHx_jFjEjFgJiDgGiBfLiDfOiCpAiOpLiCnPiClNiDiBiDiCiDiKiDhEiDeAiDeDiDiLiCmJiCoGiCoJ_xHqqkZx_FCUndoArchive_xZkqqHx_iCpAiNoMjAkM_xHqqkZx_ -----
	CMemFile file;
	file.Attach(bypData, lDataSize);
	FCUndoArchive ar(&file, FD_ARCHIVE_LOAD);
	ar.SetDocument(g_pDoc);

	// _xZkqqHx_iKmCiLkLiDeOiDiJiDfIiBeCiDgGiBfLiDfOiCmMiJlMjDmHiCnNiNjOiCnNiCmJiOgHjHhAiBeC_xHqqkZx_
	FCEnv envSub;
	FCConvEnv convEnv(&envSub);
	// _xZkqqHx_iDhCiDiFiBfLiCmJiKnGiCoNiCoJjDpMjHmNiCmNjGlDiCkCiCmMiCmFiBeB_xHqqkZx_PrepareStreamIn()_xZkqqHx_iCmNjFhDjHhGiBeC_xHqqkZx_
	//	g_pView->PrepareStreamIn();
	// InStream_xZkqqHx_iCmJjEpFiCkGiCmE_xHqqkZx_ID_xZkqqHx_iDgFiBfLiDhFiDiLiCpAiMpAiKlHiBeC_xHqqkZx_
	FCObjIDTbl idtable;
	DWORDSet stObjLabel;
	// _xZkqqHx_jFjEjFgJ_xHqqkZx_ID_xZkqqHx_iDgFiBfLiDhFiDiLiCpAiBeBiDiKiDfFiBfLiDhF_xHqqkZx_ID_xZkqqHx_iCpAjGiEiCnPiCmEiPiJiKpKiJlLiBeC_xHqqkZx_
	CFCFoundDoc::InitObjIdTblByReservedId(idtable);
	FC2Fold<FCObjIDTbl*, DWORDSet*> oitpBackup = g_pDoc->SetObjIDTbl(&idtable, &stObjLabel);
	// InStream_xZkqqHx_iCmJjEpFiCkGiCmEiDfGiBfLiDgHiDhNiDgMiBfLiDfHiDiDiCpAiMpAiKlHiBeC_xHqqkZx_
	FCSheetManager sheetManager;
	FCSheetManager* pSMOrig = g_pDoc->SetSheetManager(&sheetManager);
	//----- _xZkqqHx_iDiBiDiCiDiKiDhEiDeAiDeDiDiLiCkJiCoHiDgGiBfLiDfOiCpAjDmHiCnNiNjOiCnO_xHqqkZx_ -----
	// ChipEditor_xZkqqHx_iCmNiBeBiDgGiBfLiDfOjDgGiCkLiPgPiClFiCmJ_xHqqkZx_OutStream_xZkqqHx_iClFiCkJiOgHiCoNiCmIiCkCiClNiCnPiBeB_xHqqkZx_
	// InHeader,COleServerDoc::Serialize(ar)_xZkqqHx_iOmAiNhDiClFiCmIiCkCiBeC_xHqqkZx_
	envSub.InStream(ar);		// _xZkqqHx_iDfEiDhFiKmCiLkLiCnGiKmCiLkLiCpAiIoKiOjOjDmHiNjOiCnNiBeC_xHqqkZx_
	g_pDoc->SheetManager()->InStream(ar);		// ID_xZkqqHx_iDgFiBfLiDhFiDiLiCmJjFjEjFgJiCpAjDmHiNjOiCnOiBeC_xHqqkZx_
	// _xZkqqHx_jBnCjEpAiClFiCmEiCkCiClNiDfGiBfLiDgHiDhNiDgMiBfLiDfHiDiDiCpAjFjMiLeBiBeC_xHqqkZx_
	(void)g_pDoc->SetSheetManager(pSMOrig);
	// _xZkqqHx_jBnOjEpAiClFiCmEiCkCiClN_xHqqkZx_ID_xZkqqHx_iDgFiBfLiDhFiDiLiCpAjGnPiClHiBeC_xHqqkZx_
	g_pDoc->SetObjIDTbl(oitpBackup.first, oitpBackup.second);
	ar.Close();
	delete[] bypData;
	//----- _xZkqqHx_iPjBiCkLiNjOiCnMiCoKiClNiDgGiBfLiDfOjCiGiCmMiKmCiLkLiCpAjDgPjIfOiClHiCoJ_xHqqkZx_ -----
	// _xZkqqHx_iDgAiDgCiDhGiBeFiDeBiDiNiBfLiOkJjBmMiCmNiJlMiKmCiLkLiCnGjDgPjIfOiClHiCoJiCkKiBeBiDgAiDgCiDhGiBeFiDeBiDiNiBfLjCiGiCmF_xHqqkZx_
	// _xZkqqHx_iOgHiCoNiCoKiCmEiCkCiCoJiKmCiLkLjCgMiCmNjGhLjDgPjIfOiClFiCmEiClFiCnMiCkEiBeC_xHqqkZx_
	// _xZkqqHx_iDfKiDgCiDfGiDiHiDjDiCpAiKeKiOgOiClHiCoJiBeC_xHqqkZx_
	g_pDoc->SessionBegin();
	struct myFunc1
	{
		static BOOL myConvertEnvProp (FCObjDynabase* pObj, void* data)
		{
			FCConvEnv* pConvEnv = (FCConvEnv*)data;
			pObj->ConvertEnvProp(pConvEnv);	// _xZkqqHx_jFjEjFgJiCmMiKmCiLkLjBkOjAkLiCpA_xHqqkZx_"_xZkqqHx_iDfEiDhFiKmCiLkL_xHqqkZx_ID<->_xZkqqHx_iKmCiLkL_xHqqkZx_ID"_xZkqqHx_jFmPiKlHiBeC_xHqqkZx_
											// _xZkqqHx_jDoAjFjEiCmFiDfCiDhNiDjDiDgIjEkNiNhDiCmJjCiNiInDiBeC_xHqqkZx_
			return TRUE;
		}
	};
	// _xZkqqHx_jBfDiCmEiCmMjFjEjFgJiCmJjBmOiClFiCmEiBeB_xHqqkZx_myConvertEnvProp _xZkqqHx_iKnGjAjEiCpAiOmAiNhDiClHiCoJiBeC_xHqqkZx_
	sheetManager.CallForAllObject(myFunc1::myConvertEnvProp, &convEnv);
	// _xZkqqHx_iLeMjIfOiDfKiDgCiDfGiDiHiDjDiCmMiPeJjHlJiBeC_xHqqkZx_
	g_pDoc->SessionEnd();

	// _xZkqqHx_jFjEjFgJiCpAiDiMiDfCiBfLiDgIiCmJjDgPjIfOiBeC_xHqqkZx_
	ReceiveRecFromSheet(sheetManager);
	//----- _xZkqqHx_iPeJjHlJiPiIjHjN_xHqqkZx_ -----
	struct myFunc2
	{
		static BOOL myDeleteObject (FCObjDynabase* pObj, void* data)
		{
//----- 02.05.29 Fukushiro M. _xZkqqHx_iNoNiPjMiOgO_xHqqkZx_ (Molip_xZkqqHx_iCpA_xHqqkZx_OLE_xZkqqHx_iCmGiClFiCmEiDhJiBfLiDfIiDgHiClFiClNjAoGiCmMiDeBiDhGiDiKiCkJiCoHiBeB_xHqqkZx_Molip_xZkqqHx_iNmEjFnCiPfHiCkKiCmFiCkLiCmIiCkNiCmIiCmBiCmEiClFiCnMiCkEiBeC_xHqqkZx_)-----
//			// _xZkqqHx_jFjEjFgJiCmMiPeJjCfLiPiIjHjNiBeC_xHqqkZx_OLE_xZkqqHx_jFjEjFgJiCmMiPoKiNiHiBeB_xHqqkZx_OLE_xZkqqHx_iDgGiBfLiDfOiCmMjGjFiPmBiCpAiNhDiCkEiBeC_xHqqkZx_
//			pObj->Terminate();
//----- 02.05.29 Fukushiro M. _xZkqqHx_iNoNiPjMiPeJ_xHqqkZx_ (Molip_xZkqqHx_iCpA_xHqqkZx_OLE_xZkqqHx_iCmGiClFiCmEiDhJiBfLiDfIiDgHiClFiClNjAoGiCmMiDeBiDhGiDiKiCkJiCoHiBeB_xHqqkZx_Molip_xZkqqHx_iNmEjFnCiPfHiCkKiCmFiCkLiCmIiCkNiCmIiCmBiCmEiClFiCnMiCkEiBeC_xHqqkZx_)-----
			// _xZkqqHx_jFjEjFgJiOkJjBmMiCmMiNoNiPjMiBeC_xHqqkZx_
			delete pObj;
			return TRUE;
		}
	};
	// _xZkqqHx_jBfDiCmEiCmMjFjEjFgJiCmJjBmOiClFiCmEiBeB_xHqqkZx_myDeleteObject _xZkqqHx_iKnGjAjEiCpAiOmAiNhDiClHiCoJiBeC_xHqqkZx_
	sheetManager.CallForAllObject(myFunc2::myDeleteObject, 0);
	// _xZkqqHx_iDiMiDfCiBfLiDgIiPeDjAlDiCpAjAnNjCoIiBeC_xHqqkZx_
	m_iRecModified = 3;	// 0:_xZkqqHx_jGkCiPeDjAlDiBeB_xHqqkZx_1:_xZkqqHx_iPeDjAlDjCiGiBeB_xHqqkZx_2:_xZkqqHx_iOpDjAeNjCiGiBeB_xHqqkZx_3:_xZkqqHx_iOpDjAeNiNmPiCnNiBeC_xHqqkZx_
	// _xZkqqHx_iPeJjHlJiDiBiDgCiDfKiBfLiDfHiCpAiDhMiDfIiDgHiBeC_xHqqkZx_
	PostMessage(WM_USER_EDITDRAW_QUITED);
} // CFCDlgCommonEditorModify::OnReceiveEditdrawStream.

BEGIN_MESSAGE_MAP(CFCDlgCommonEditorModify, BASE_CLASS)
	//{{AFX_MSG_MAP(CFCDlgCommonEditorModify)
	ON_BN_CLICKED(IDC_CPM_BTN_KILL_EDITOR, OnCpmBtnKillEditor)
	//}}AFX_MSG_MAP
	ON_MESSAGE(WM_USER_EDITDRAW_START, OnUserEditdrawStart)
	ON_MESSAGE(WM_USER_EDITDRAW_QUITED, OnUserEditdrawQuited)
	ON_MESSAGE(WM_USER_FROM_EDITDRAW, OnUserFromEditdraw)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CFCDlgCommonEditorModify _xZkqqHx_iDiBiDgCiDfKiBfLiDfH_xHqqkZx_ _xZkqqHx_iDgOiDjDiDgIiDiJ_xHqqkZx_

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	CFCDlgCommonEditorModify::OnInitDialog
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDfPiDeDiDeBiDiNiDePiPiJiKpKiJlLiOjOiCmJiOmAiNhDiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	01.04.08 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
BOOL CFCDlgCommonEditorModify::OnInitDialog ()
{
	// Superclass_xZkqqHx_iKnGjAjEiBeC_xHqqkZx_
	BASE_CLASS::OnInitDialog();
	// _xZkqqHx_iDfPiDeDiDeBiDiNiDePiCmMjCfAiImKjFfMiOkGiCpAjAnNjCoIiClHiCoJiBeC_xHqqkZx_
	::SetUnitString(m_hWnd);
	// _xZkqqHx_jHjIiCkLjIhCjBmOiJjOjFlGiOjKjHpBiCmMjAnNjCoIiCpAiNhDiCkEiBeC_xHqqkZx_
	::RightByLeftHand(m_hWnd);
	// _xZkqqHx_iDfPiDeDiDeBiDiNiDePiCpAiDhNiDeFiDfIiImKjChFiCmJiInKjDkOiBeC_xHqqkZx_
	if (!IsKindOf(RUNTIME_CLASS(CPropertyPage)))
		::FFJustifyWindow(m_hWnd);
	// _xZkqqHx_iDeHiDgGiDeCiDgCiDgHiDgIiDiNiBfLiLeOjDkOiDiBiDgCiDfKiBfLiDfHiBeC_xHqqkZx_
	PostMessage(WM_USER_EDITDRAW_START);
	return TRUE;  // _xZkqqHx_iDfCiDjDiDgHiDiNiBfLiDiLiCmJiDhEiDeIiBfLiDeKiDfIiCpAjAnNjCoIiClFiCmIiCkCiCmGiCkLiBeBjGnPiCoIjCgMiCmN_xHqqkZx_ TRUE _xZkqqHx_iCmGiCmIiCoIiCnMiClH_xHqqkZx_
	              // _xZkqqHx_jHoBiKeP_xHqqkZx_: OCX _xZkqqHx_iDhGiDiNiDhAiDgFiDeC_xHqqkZx_ _xZkqqHx_iDhJiBfLiDfHiCmMjGnPiCoIjCgMiCmN_xHqqkZx_ FALSE _xZkqqHx_iCmGiCmIiCoIiCnMiClH_xHqqkZx_
} // CFCDlgCommonEditorModify::OnInitDialog.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	CFCDlgCommonEditorModify::OnUserEditdrawStart
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDeHiDgGiDeCiDgCiDgHiDgIiDiNiBfLiCpAiLeOjDkOiClHiCoJiDiBiDgCiDfKiBfLiDfHiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	_xZkqqHx_jGkCiOgHjHhAiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jFnEjCgM_xHqqkZx_>	1
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	01.04.08 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
LRESULT CFCDlgCommonEditorModify::OnUserEditdrawStart (WPARAM, LPARAM)
{
	CMemFile file;
	FCUndoArchive ar(&file, FD_ARCHIVE_STORE);
	ar.SetDocument(g_pDoc);
	FCSheetManager sheetManager;
	// _xZkqqHx_iDiMiDfCiBfLiDgIiCmMjFjEjFgJiCpAiDfGiBfLiDgHiCmJjDgPjIfOiBeC_xHqqkZx_
	wchar_t szName[FD_ENV_NAME_LEN];
	SetRecToSheet(sheetManager, szName);
	// _xZkqqHx_iDfGiBfLiDgHiDhNiDgMiBfLiDfHiDiDiCpAjChFiCkLiKlHiCkGiCoJiBeC_xHqqkZx_
	FCSheetManager* pSMOrig = g_pDoc->SetSheetManager(&sheetManager);
	// _xZkqqHx_jGlMjBePiCpAiPjBiCkLiNjOiCnOiBeC_xHqqkZx_
	ar << WORD(wcslen(szName));
	ar.Write(szName, sizeof(szName[0]) * wcslen(szName));
	g_pEnv->OutStream(ar, TRUE, FALSE);			// _xZkqqHx_iKmCiLkLiPoOjFpBiCpAiPjBiCkLiNjOiCnOiBeC_xHqqkZx_
// 06.06.23 Fukushiro M. 1_xZkqqHx_iNhDjFmPiNfI_xHqqkZx_ ()
//	g_pDoc->SheetManager()->OutStream(ar, TRUE);	// _xZkqqHx_iLpDiCmMjFjEjFgJiCpAiPjBiCkLiNjOiCnOiBeC_xHqqkZx_
	g_pDoc->SheetManager()->OutStream(ar, TRUE, FALSE);	// _xZkqqHx_iLpDiCmMjFjEjFgJiCpAiPjBiCkLiNjOiCnOiBeC_xHqqkZx_
	ar.Close();
	// _xZkqqHx_jBnCjEpAiClFiCmEiCkCiClNiDfGiBfLiDgHiDhNiDgMiBfLiDfHiDiDiCpAjFjMiLeBiBeC_xHqqkZx_
	(void)g_pDoc->SetSheetManager(pSMOrig);
	long lLen = long(file.GetLength());
	BYTE* pMem = file.Detach();
	// _xZkqqHx_iDeHiDgGiDeCiDgCiDgHiDgIiDiNiBfLiCpAiLeOjDkOiBjFiDgGiBfLiDfOjDfNjBjHiBeC_xHqqkZx_
	if (!ExecEditdraw(lLen, pMem))
		PostMessage(WM_USER_EDITDRAW_QUITED);
	// _xZkqqHx_iDgPiDgCiDhEiDeAiCpAiKeKjFpKiBeC_xHqqkZx_
	::free(pMem);
	return 1;
} // CFCDlgCommonEditorModify::OnUserEditdrawStart.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	CFCDlgCommonEditorModify::OnUserEditdrawQuited
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDeHiDgGiDeCiDgCiDgHiDgIiDiNiBfLiCkKiPeJjHlJiClFiClNiOjOiCmJiOmAiNhDiClDiCoKiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	_xZkqqHx_jGkCiOgHjHhAiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jFnEjCgM_xHqqkZx_>	1
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	01.04.08 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
LRESULT CFCDlgCommonEditorModify::OnUserEditdrawQuited (WPARAM, LPARAM)
{
	// _xZkqqHx_iDgGiBfLiDfOiOpDjAeNjCiGiCmIiCoHiCmOiPiIjHjNiClFiCmIiCkCiBeC_xHqqkZx_
	if (m_iRecModified == 2) return 1;	// 0:_xZkqqHx_jGkCiPeDjAlDiBeB_xHqqkZx_1:_xZkqqHx_iPeDjAlDjCiGiBeB_xHqqkZx_2:_xZkqqHx_iOpDjAeNjCiGiBeB_xHqqkZx_3:_xZkqqHx_iOpDjAeNiNmPiCnNiBeC_xHqqkZx_
	if (m_iRecModified == 3)
		BASE_CLASS::OnOK();
	else
		BASE_CLASS::OnCancel();
	return 1;
} // CFCDlgCommonEditorModify::OnUserEditdrawQuited.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	CFCDlgCommonEditorModify::OnUserFromEditdraw
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDeHiDgGiDeCiDgCiDgHiDgIiDiNiBfLiCkJiCoHiCmMiDfCiDhNiDjDiDgIiCpAiOpDjAeNiClFiClNiCmGiCkLiOmAiNhDiClDiCoKiCoJiBeC_xHqqkZx_
 *			Molip Draw_xZkqqHx_iDiCiBfLiDgIiCmMiOjOiCmJjHeMiMpIiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	wParam	:_xZkqqHx_iDfCiDhNiDjDiDgIiBeC_xHqqkZx_
 *			lParam	:_xZkqqHx_iDfCiDhNiDjDiDgIjFmKiCmMiIpIjAjEiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jFnEjCgM_xHqqkZx_>	_xZkqqHx_iPoNiCmJ_xHqqkZx_1.
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	01.04.08 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
LRESULT CFCDlgCommonEditorModify::OnUserFromEditdraw (WPARAM wParam, LPARAM lParam)
{
	switch (wParam)
	{
	case FDFC_RECEIVE_EDITDRAW_STREAM:	// _xZkqqHx_iDgGiBfLiDfOiCmMiOpDiCkPiOoGiCoIjHhGiLiBiBeC_xHqqkZx_
		OnReceiveEditdrawStream(reinterpret_cast<HWND>(lParam));
		break;
	}
	return 1;
} // CFCDlgCommonEditorModify::OnUserFromEditdraw.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	CFCDlgCommonEditorModify::OnCpmBtnKillEditor
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDhLiDfOiDjDiBhFiDeHiDgGiDeCiDgCiDgHiDgIiDiNiBfLiLkNjAkHiPeJjHlJiBhGiCkJiCoHiOmAiNhDiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	01.04.08 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
void CFCDlgCommonEditorModify::OnCpmBtnKillEditor ()
{
	// _xZkqqHx_iDeHiDgGiDeCiDgCiDgHiDgIiDiNiBfLiCnGiDeBiDhGiDiKiPeJjHlJjGlNjHnPiBeC_xHqqkZx_
	::PostMessage(m_hwndEditdraw, WM_USER_TO_EDITDRAW, FDTC_APP_CLOSE, 0);
	// _xZkqqHx_iDiMiDfCiBfLiDgIiPeDjAlDiCpAjAnNjCoIiBeC_xHqqkZx_
	m_iRecModified = 0;	// 0:_xZkqqHx_jGkCiPeDjAlDiBeB_xHqqkZx_1:_xZkqqHx_iPeDjAlDjCiGiBeB_xHqqkZx_2:_xZkqqHx_iOpDjAeNjCiGiBeB_xHqqkZx_3:_xZkqqHx_iOpDjAeNiNmPiCnNiBeC_xHqqkZx_
} // CFCDlgCommonEditorModify::OnCpmBtnKillEditor.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	CFCDlgCommonEditorModify::OnCancel
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iBhF_xHqqkZx_ESC_xZkqqHx_iBhGiDeMiBfLiBeBiBhFiDeMiDiDiDjDiDfKiDiLiBhGiDhLiDfOiDjDiCkJiCoHiOmAiNhDiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	01.04.08 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
void CFCDlgCommonEditorModify::OnCancel ()
{
	// _xZkqqHx_iJlNiCoAiPiIjHjNiClFiCmIiCkCiBeC_xHqqkZx_
} // CFCDlgCommonEditorModify::OnCancel.
