// HiDocTool.cpp : _xZkqqHx_iDeBiDhGiDiKiDfAiBfLiDfGiDiHiDjDjHhAiDeOiDiJiDfIiCmMjCoIiLgAiCpAiNhDiCkCiCnMiClHiBeC_xHqqkZx_
//

#include "StdAfx.h"
#include "HiDocTool.h"
#include "UtilStr.h"			// For FFLoadWString.
#include "InitialMessageDlg.h"	// For CInitialMessageDlg.
#include "HiDocToolDlg.h"		// For CHiDocToolDlg.

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

// _xZkqqHx_iDeBiDhGiDiKiCmMiDgPiBfLiDfHiDiHiDjDiBeCiDiKiDfMiBfLiDfI_xHqqkZx_ID_xZkqqHx_iCkKjFmPiNfIiCmJiCmIiCoJiPoKiNiHiCmJiCmNjFmPiNfIiClHiCoJiClBiCmGiBeC_xHqqkZx_
#define FD_APPLICATION_VERSION	L"4.1"

static const _TCHAR* FD_MOVE_DESKTOP	= _T("desktop");
static const int FD_MOVE_DESKTOP_LEN	= _tcslen(FD_MOVE_DESKTOP);

//----- 06.03.17 Fukushiro M. _xZkqqHx_jCmHiJmBiOgO_xHqqkZx_ ()-----
static FCRegData s_reg;
FCRegData* g_pReg = &s_reg;
//----- 06.03.17 Fukushiro M. _xZkqqHx_jCmHiJmBiPeJ_xHqqkZx_ ()-----

/////////////////////////////////////////////////////////////////////////////
// CHiDocToolApp

BEGIN_MESSAGE_MAP(CHiDocToolApp, CWinApp)
	//{{AFX_MSG_MAP(CHiDocToolApp)
		// _xZkqqHx_iDiBiDiC_xHqqkZx_ - ClassWizard _xZkqqHx_iCmNiClBiCmMiImKjChFiCmJiDhNiDgCiDhDiDjDiDePjHhAiCmMiDhNiDeOiDiNiCpAjCmHiJmBiCnMiClNiCmNiNoNiPjMiClFiCnMiClHiBeC_xHqqkZx_
		//        _xZkqqHx_iClBiCmMiImKjChFiCmJjAlGjAkMiClDiCoKiCoJiDfCiBfLiDgIiCpAjFnCiPfHiClFiCmIiCkCiCmFiCkNiClOiClDiCkCiBeC_xHqqkZx_
	//}}AFX_MSG
	ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CHiDocToolApp _xZkqqHx_iDeOiDiJiDfIiCmMiNfMjChK_xHqqkZx_

CHiDocToolApp::CHiDocToolApp ()
{
	// TODO: _xZkqqHx_iClBiCmMiImKjChFiCmJiNfMjChKjHhAiCmMiDfCiBfLiDgIiCpAjCmHiJmBiClFiCmEiCkNiClOiClDiCkCiBeC_xHqqkZx_
	// _xZkqqHx_iClBiClBiCmJ_xHqqkZx_ InitInstance _xZkqqHx_jCiGiCmMiPgEjHhGiCmIiPiJiKpKiJlLiPiIjHjNiCpAiClHiCnHiCmEiLeMiPhBiClFiCmEiCkNiClOiClDiCkCiBeC_xHqqkZx_
//----- 06.04.25 Fukushiro M. _xZkqqHx_jCmHiJmBiOgO_xHqqkZx_ ()-----
	// _xZkqqHx_iDiKiDfMiBfLiDfIjHhAiDeDiDjDiDfIiDfOiDjDiDfIiBeC_xHqqkZx_
	m_hResInstance = NULL;
//----- 06.04.25 Fukushiro M. _xZkqqHx_jCmHiJmBiPeJ_xHqqkZx_ ()-----
} // CHiDocToolApp::CHiDocToolApp.

/////////////////////////////////////////////////////////////////////////////
// _xZkqqHx_jHeCiIoKiCmM_xHqqkZx_ CHiDocToolApp _xZkqqHx_iDeJiDhFiDfHiDeGiDeOiDgH_xHqqkZx_

CHiDocToolApp theApp;

/*************************************************************************
 * <_xZkqqHx_iDeOiDiJiDfI_xHqqkZx_>	CFCCommandLineInfo
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iIpIjAjEjDjJiCpAiJpAiOnPiClHiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	05.08.18 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
class CFCCommandLineInfo : public CCommandLineInfo
{
public:
	CFCCommandLineInfo ();
	virtual void ParseParam (LPCTSTR lpszParam, BOOL bFlag, BOOL bLast);

public:
	BOOL	m_bIsMoveToDesktop;	// _xZkqqHx_iDgGiDfIiDeOiDgHiDgCiDhGiCmJiInKjDkOiClHiCoJiCkJiBeI_xHqqkZx_
}; // class CFCCommandLineInfo.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	CFCCommandLineInfo::CFCCommandLineInfo
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDfCiDjDiDfIiDgHiDiJiDeOiDfOiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	02.02.27 Fukushiro M. _xZkqqHx_iDfCiDiBiDjDiDgHiNoMjAkMiBeC_xHqqkZx_
 *************************************************************************/
CFCCommandLineInfo::CFCCommandLineInfo ()
				:	m_bIsMoveToDesktop(FALSE)		// _xZkqqHx_iDgGiDfIiDeOiDgHiDgCiDhGiCmJiInKjDkOiClHiCoJiCkJiBeI_xHqqkZx_
{
} // CFCCommandLineInfo::CFCCommandLineInfo.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	CFCCommandLineInfo::ParseParam
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	ParseCommandLine_xZkqqHx_iKnGjAjEiCmJiCkIiCkCiCmEiBeBiDfCiDhNiDjDiDgIiDiJiDeDiDjDiCmMiJpAjAmNiCpAiNhDiCkEiBeC_xHqqkZx_
 *
 * <_xZkqqHx_iIpIjAjE_xHqqkZx_>	lpszParam	:_xZkqqHx_iDfCiDhNiDjDiDgIiDiJiDeDiDjDiCmMiIpIjAjEiBeC_xHqqkZx_
 *			bFlag		:_xZkqqHx_iDhEiDiJiDePiCmMiPoKiNiH_xHqqkZx_ TRUE_xZkqqHx_iBeBiDhAiDiJiDiBiBfLiDfOiCmMiPoKiNiH_xHqqkZx_ FALSE_xZkqqHx_iBeC_xHqqkZx_
 *			bLast		:_xZkqqHx_iDfCiDhNiDjDiDgIiDiJiDeDiDjDiCmMiNmFiMoDiCmMiDhEiDiJiDePiBeFiDhAiDiJiDiBiBfLiDfOiCmM_xHqqkZx_
 *						_xZkqqHx_iPoKiNiHiBeB_xHqqkZx_TRUE_xZkqqHx_iBeC_xHqqkZx_
 *
 * <_xZkqqHx_iJpAjAoA_xHqqkZx_>	_xZkqqHx_iDfCiDhNiDjDiDgIiDiJiDeDiDjDiCmMiMgAiOkO_xHqqkZx_
 *				MolipDraw.exe
 *				MolipDraw.exe -usrtmpl
 *				MolipDraw.exe -repair
 *				MolipDraw.exe _xZkqqHx_iDhEiDeAiDeDiDiLjGlM_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	05.08.18 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
void CFCCommandLineInfo::ParseParam (LPCTSTR lpszParam, BOOL bFlag, BOOL bLast)
{
	if (bFlag)
	//----- _xZkqqHx_iDhEiDiJiDeP_xHqqkZx_(/xxx, -xxx)_xZkqqHx_iCmMiPoKiNiH_xHqqkZx_ -----
	{
		if (_tcsnicmp(lpszParam, FD_MOVE_DESKTOP, FD_MOVE_DESKTOP_LEN) == 0)
		//----- -desktop -----
		{
			// _xZkqqHx_iDgGiDfIiDeOiDgHiDgCiDhGiCmJiInKjDkOiClHiCoJiCkJiBeI_xHqqkZx_
			m_bIsMoveToDesktop = TRUE;
		} else
		{
			CCommandLineInfo::ParseParam(lpszParam, bFlag, bLast);
		}
	} else
	//----- _xZkqqHx_iDhEiDiJiDePiImIiKePiCmMiPoKiNiH_xHqqkZx_ -----
	{
		CCommandLineInfo::ParseParam(lpszParam, bFlag, bLast);
	}
} // CFCCommandLineInfo::ParseParam.

/////////////////////////////////////////////////////////////////////////////
// CHiDocToolApp _xZkqqHx_iDeOiDiJiDfIiCmMiPiJiKpKiJlL_xHqqkZx_

BOOL CHiDocToolApp::InitInstance ()
{
	// _xZkqqHx_jFfHiPiAjDeJiCmIiPiJiKpKiJlLiPiIjHjN_xHqqkZx_
	// _xZkqqHx_iCoAiClFiClBiCoKiCoHiCmMiLeAjEfMiCpAiOgHjHhAiClJiClIiBeBiOmAiNhDiDhEiDeAiDeDiDiLiCmMiDfEiDeDiDfJiCpAiPkMiClDiCkNiClFiClNiCkP_xHqqkZx_
	//  _xZkqqHx_iCoKiCmOiImIiJlKiCmMjDmBjCoIiCmMiPiJiKpKiJlLiDiLiBfLiDgAiDjDiCmMjCiGiCkJiCoHjFhDjFeLjHhGiCmIiCoAiCmMiCpAiNoNiPjMiClFiCmE_xHqqkZx_
	//  _xZkqqHx_iCkNiClOiClDiCkCiBeC_xHqqkZx_

//----- 06.04.24 Fukushiro M. _xZkqqHx_jCmHiJmBiOgO_xHqqkZx_ ()-----
	// _xZkqqHx_iDiKiDfMiBfLiDfI_xHqqkZx_DLL_xZkqqHx_iCpAjDmHiCnNiPgPiClHiBeC_xHqqkZx_
	m_hResInstance = ::LoadLibrary(_T("HiDocToolRes.dll"));
	if (m_hResInstance <= (HINSTANCE)HINSTANCE_ERROR)
	//----- DLL_xZkqqHx_iCkKiDiNiBfLiDgIiCmFiCkLiCmIiCkCiPoKiNiH_xHqqkZx_ -----
	{
		// _xZkqqHx_iDeHiDiJiBfLiDiBiDgCiDfKiBfLiDfHiBeCiDiKiDfMiBfLiDfI_xHqqkZx_ID_xZkqqHx_iCkKiOgHiCkGiCmIiCkCiClNiCnPiBeBjFlGiOjKjHpBiCpAjClMiPjBiCkLiBeC_xHqqkZx_
		AfxMessageBox(_T("Cannot load the resource DLL"));
		return FALSE;
	}
	// _xZkqqHx_iDiKiDfMiBfLiDfIiCpAjAnNjCoIiBeC_xHqqkZx_
	AfxSetResourceHandle(m_hResInstance);

	if (FFLoadWString(IDS_RESOURCE_VERSION) != FD_APPLICATION_VERSION)
	//----- _xZkqqHx_iDiKiDfMiBfLiDfI_xHqqkZx_DLL_xZkqqHx_iCmMiDgPiBfLiDfHiDiHiDjDiCmGiDeBiDhGiDiKiDgPiBfLiDfHiDiHiDjDiCkKiInJiCmIiCoJiPoKiNiH_xHqqkZx_ -----
	{
		// _xZkqqHx_iDeHiDiJiBfLiDiBiDgCiDfKiBfLiDfHiBeCiDiKiDfMiBfLiDfI_xHqqkZx_ID_xZkqqHx_iCkKiOgHiCkGiCmIiCkCiClNiCnPiBeBjFlGiOjKjHpBiCpAjClMiPjBiCkLiBeC_xHqqkZx_
		AfxMessageBox(_T("Incorrect version of resource DLL"));
		return FALSE;
	}
//----- 06.04.24 Fukushiro M. _xZkqqHx_jCmHiJmBiPeJ_xHqqkZx_ ()-----

#ifdef _AFXDLL
	Enable3dControls();			// _xZkqqHx_iLkEjHeM_xHqqkZx_ DLL _xZkqqHx_jDoAiCmF_xHqqkZx_ MFC _xZkqqHx_iCpAiOgHiCkEiPoKiNiHiCmNiClBiClBiCpAiDfCiBfLiDiLiClFiCmEiCkNiClOiClDiCkCiBeC_xHqqkZx_
#else
	Enable3dControlsStatic();	// MFC _xZkqqHx_iCmGjAmDjDeJiCmJiDiKiDjDiDeOiClHiCoJiPoKiNiHiCmNiClBiClBiCpAiDfCiBfLiDiLiClFiCmEiCkNiClOiClDiCkCiBeC_xHqqkZx_
#endif

	// DDE_xZkqqHx_iBeB_xHqqkZx_file open _xZkqqHx_iCmIiCmHjFfHiPiAiCmMiDfGiDeGiDiL_xHqqkZx_ _xZkqqHx_iDfCiDhNiDjDiDgIiCmMiDfCiDhNiDjDiDgIiDiJiDeDiDjDiCpAiJpAjAmNiClFiCnMiClHiBeC_xHqqkZx_
	CFCCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);
	// _xZkqqHx_jClMjAnKiOmAiNhDiBeI_xHqqkZx_
	BOOL bIsDirect = !cmdInfo.m_strFileName.IsEmpty();

	if (!bIsDirect)
	//----- _xZkqqHx_jClMjAnKiOmAiNhDiCmFiCmNiCmIiCkCiPoKiNiH_xHqqkZx_ -----
	{
		// _xZkqqHx_iLeOjDkOiOjOiDiBiDgCiDfKiBfLiDfHiCpAjFfMiOkGiBeC_xHqqkZx_
		CInitialMessageDlg().DoModal();
	}
	// _xZkqqHx_iDiBiDeDiDjDiDfPiDeDiDeBiDiNiDePiBeC_xHqqkZx_
	CHiDocToolDlg dlg(	bIsDirect,
						TStrToWStr(cmdInfo.m_strFileName),
						cmdInfo.m_bIsMoveToDesktop);
	m_pMainWnd = &dlg;
	dlg.DoModal();

	// _xZkqqHx_iDfPiDeDiDeBiDiNiDePiCkKjFmCiClGiCoHiCoKiCmEiCkJiCoHiDeBiDhGiDiKiDfAiBfLiDfGiDiHiDjDiCmMiDiBiDgCiDfKiBfLiDfH_xHqqkZx_ _xZkqqHx_iDhMiDjDiDhGiCpAiKeKiOgOiClHiCoJiCoGiCoIiCmNiBeB_xHqqkZx_
	// _xZkqqHx_iDeBiDhGiDiKiDfAiBfLiDfGiDiHiDjDiCpAiPeJjHlJiClHiCoJiClNiCnPiCmJ_xHqqkZx_ FALSE _xZkqqHx_iCpAjFnEiClFiCmEiCkNiClOiClDiCkCiBeC_xHqqkZx_
	return FALSE;
} // CHiDocToolApp::InitInstance.

/*************************************************************************
 * <_xZkqqHx_iKnGjAjE_xHqqkZx_>	CHiDocToolApp::ExitInstance
 *
 * <_xZkqqHx_iLeAjEfM_xHqqkZx_>	_xZkqqHx_iDeBiDhGiDiKiPeJjHlJiOjOiCmJiOmAiNhDiClDiCoKiCoJiBeC_xHqqkZx_
 *
 * <_xZkqqHx_jHjKjHpA_xHqqkZx_>	06.04.25 Fukushiro M. _xZkqqHx_iNoMjAkM_xHqqkZx_
 *************************************************************************/
int CHiDocToolApp::ExitInstance ()
{
	if ((HINSTANCE)HINSTANCE_ERROR < m_hResInstance)
	{
		// _xZkqqHx_iDiKiDfMiBfLiDfI_xHqqkZx_DLL_xZkqqHx_iCpAiJpAjFpKiBeC_xHqqkZx_
		::FreeLibrary(m_hResInstance);
		m_hResInstance = NULL;
	}

	// Baseclass_xZkqqHx_iKnGjAjEiOmAiNhDiBeC_xHqqkZx_
	return CWinApp::ExitInstance();
} // CHiDocToolApp::ExitInstance.
