2024-12-21 10:04:04 +08:00
|
|
|
|
#include "stdafx.h"
|
|
|
|
|
|
#include "DnControlData.h"
|
|
|
|
|
|
|
|
|
|
|
|
CDnControlData::CDnControlData()
|
|
|
|
|
|
{
|
|
|
|
|
|
m_vecCtrlPosData.clear();
|
|
|
|
|
|
m_szLanguageParam.Empty();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CDnControlData::~CDnControlData()
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HRESULT CDnControlData::SetControlDataFromLocalFile( CString szFilePath, CRect* pRect, int nMaxCnt )
|
|
|
|
|
|
{
|
|
|
|
|
|
char* pBuff = new char[szFilePath.GetLength() + 1];
|
|
|
|
|
|
strncpy(pBuff, CT2A(szFilePath), szFilePath.GetLength() + 1);
|
|
|
|
|
|
|
|
|
|
|
|
// xml<6D><6C><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>о<EFBFBD><D0BE>´<EFBFBD>.
|
|
|
|
|
|
if( !LoadXMLFile(pBuff) )
|
|
|
|
|
|
{
|
|
|
|
|
|
LogWnd::TraceLog(_T("ControlData XML<4D><4C><EFBFBD><EFBFBD> <20>ҷ<EFBFBD><D2B7><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>!!"));
|
|
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// <20><>Ʈ<EFBFBD>ѿ<EFBFBD> <20><>ġ<EFBFBD><C4A1> <20><><EFBFBD><EFBFBD><EFBFBD>ش<EFBFBD>.
|
|
|
|
|
|
if( !SetPositionData( pRect, nMaxCnt ) )
|
|
|
|
|
|
{
|
|
|
|
|
|
LogWnd::TraceLog(_T("ControlData Position Set Failed"));
|
|
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HRESULT CDnControlData::SetControlDataFromResource( int nResourceID, LPCTSTR szFileName, CRect* pRect, int nMaxCnt )
|
|
|
|
|
|
{
|
|
|
|
|
|
// xml<6D><6C><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>о<EFBFBD><D0BE>´<EFBFBD>.
|
|
|
|
|
|
if( !LoadResourceFromXMLFile(nResourceID, szFileName) )
|
|
|
|
|
|
{
|
|
|
|
|
|
LogWnd::TraceLog(_T("ControlData ResourceXML<4D><4C><EFBFBD><EFBFBD> <20>ҷ<EFBFBD><D2B7><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>!!"));
|
|
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// <20><>Ʈ<EFBFBD>ѿ<EFBFBD> <20><>ġ<EFBFBD><C4A1> <20><><EFBFBD><EFBFBD><EFBFBD>ش<EFBFBD>.
|
|
|
|
|
|
if( !SetPositionData( pRect, nMaxCnt ) )
|
|
|
|
|
|
{
|
|
|
|
|
|
LogWnd::TraceLog(_T("ControlData Position Set Failed"));
|
|
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CDnControlData::LoadXMLFile( char* szFilePath )
|
|
|
|
|
|
{
|
|
|
|
|
|
if( szFilePath == NULL )
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD> Ŭ<><C5AC><EFBFBD><EFBFBD>.
|
|
|
|
|
|
m_vecCtrlPosData.clear();
|
|
|
|
|
|
|
|
|
|
|
|
CXMLParser aParser;
|
|
|
|
|
|
{
|
|
|
|
|
|
USES_CONVERSION;
|
|
|
|
|
|
|
|
|
|
|
|
RECT RectPos;
|
|
|
|
|
|
WCHAR szRect[1024] = { '\0', };
|
|
|
|
|
|
WCHAR szType[1024] = { '\0', };
|
|
|
|
|
|
WCHAR szEnum[1024] = { '\0', };
|
|
|
|
|
|
|
|
|
|
|
|
stControlPositionData tempData;
|
|
|
|
|
|
if( !aParser.Open(szFilePath) )
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if( aParser.FirstChildElement("document",true) )
|
|
|
|
|
|
{
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
if( aParser.FirstChildElement("ContrlListData",false) )
|
|
|
|
|
|
{
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
::wcsncpy_s( szRect, _countof(szRect), aParser.GetAttribute("RectPos"),_countof(szRect) );
|
|
|
|
|
|
::wcsncpy_s( szType, _countof(szType), aParser.GetAttribute("Type"), _countof(szType) );
|
|
|
|
|
|
::wcsncpy_s( szEnum, _countof(szEnum), aParser.GetAttribute("Enum"), _countof(szEnum) );
|
|
|
|
|
|
|
|
|
|
|
|
ParsingRectData(szRect, RectPos);
|
|
|
|
|
|
tempData.nType = _wtoi(szType);
|
|
|
|
|
|
tempData.nEnum = _wtoi(szEnum);
|
|
|
|
|
|
tempData.RectPos = RectPos;
|
|
|
|
|
|
|
|
|
|
|
|
m_vecCtrlPosData.push_back(tempData);
|
|
|
|
|
|
|
|
|
|
|
|
} while(aParser.NextSiblingElement("ContrlListData"));
|
|
|
|
|
|
}
|
|
|
|
|
|
} while(aParser.NextSiblingElement("document"));
|
|
|
|
|
|
} // end of document
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(m_vecCtrlPosData.empty())
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CDnControlData::LoadResourceFromXMLFile(int nID, LPCTSTR szFileName)
|
|
|
|
|
|
{
|
|
|
|
|
|
// <20><><EFBFBD>ҽ<EFBFBD> <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD><EFBFBD>.
|
|
|
|
|
|
HMODULE hModule = ::GetModuleHandle(NULL);
|
|
|
|
|
|
HRSRC hSrc = ::FindResource( hModule, MAKEINTRESOURCE(nID), _T("XML"));
|
|
|
|
|
|
HGLOBAL hGlobal = ::LoadResource( hModule, hSrc );
|
|
|
|
|
|
char* szRes = static_cast<char*>(::LockResource(hGlobal));
|
|
|
|
|
|
LPCTSTR myStr = szFileName;
|
|
|
|
|
|
|
|
|
|
|
|
CFile file( myStr, CFile::modeCreate | CFile::modeWrite | CFile::typeBinary);
|
|
|
|
|
|
file.Write((void*)szRes, SizeofResource(AfxGetInstanceHandle(),(HRSRC)hSrc));
|
|
|
|
|
|
file.Close();
|
|
|
|
|
|
::FreeResource(hGlobal);
|
|
|
|
|
|
|
|
|
|
|
|
CString strFileName = szFileName;
|
|
|
|
|
|
char szOpenFileName[_MAX_PATH] = { 0 , };
|
|
|
|
|
|
strncpy(szOpenFileName , CT2A(strFileName), _MAX_PATH);
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD> Ŭ<><C5AC><EFBFBD><EFBFBD>.
|
|
|
|
|
|
m_vecCtrlPosData.clear();
|
|
|
|
|
|
|
|
|
|
|
|
CXMLParser aParser;
|
|
|
|
|
|
{
|
|
|
|
|
|
USES_CONVERSION;
|
|
|
|
|
|
|
|
|
|
|
|
RECT RectPos;
|
|
|
|
|
|
WCHAR szRect[1024] = { '\0', };
|
|
|
|
|
|
WCHAR szType[1024] = { '\0', };
|
|
|
|
|
|
WCHAR szEnum[1024] = { '\0', };
|
|
|
|
|
|
|
|
|
|
|
|
stControlPositionData tempData;
|
|
|
|
|
|
|
|
|
|
|
|
if( !aParser.Open(szOpenFileName) )
|
|
|
|
|
|
{
|
|
|
|
|
|
ClientDeleteFile(myStr);
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if( aParser.FirstChildElement("document",true) )
|
|
|
|
|
|
{
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
if( aParser.FirstChildElement("ContrlListData",false) )
|
|
|
|
|
|
{
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
::wcsncpy_s( szRect, _countof(szRect), aParser.GetAttribute("RectPos"),_countof(szRect) );
|
|
|
|
|
|
::wcsncpy_s( szType, _countof(szType), aParser.GetAttribute("Type"), _countof(szType) );
|
|
|
|
|
|
::wcsncpy_s( szEnum, _countof(szEnum), aParser.GetAttribute("Enum"), _countof(szEnum) );
|
|
|
|
|
|
|
|
|
|
|
|
ParsingRectData(szRect, RectPos);
|
|
|
|
|
|
tempData.nType = _wtoi(szType);
|
|
|
|
|
|
tempData.nEnum = _wtoi(szEnum);
|
|
|
|
|
|
tempData.RectPos = RectPos;
|
|
|
|
|
|
|
|
|
|
|
|
m_vecCtrlPosData.push_back(tempData);
|
|
|
|
|
|
|
|
|
|
|
|
} while(aParser.NextSiblingElement("ContrlListData"));
|
|
|
|
|
|
}
|
|
|
|
|
|
} while(aParser.NextSiblingElement("document"));
|
|
|
|
|
|
} // end of document
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ClientDeleteFile(myStr);
|
|
|
|
|
|
|
|
|
|
|
|
if(m_vecCtrlPosData.empty())
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CDnControlData::SetPositionData( CRect* pRt, int nMax )
|
|
|
|
|
|
{
|
|
|
|
|
|
if( m_vecCtrlPosData.empty())
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
RECT rect;
|
|
|
|
|
|
for( int index = 0 ; index < nMax ; ++index )
|
|
|
|
|
|
{
|
|
|
|
|
|
rect = GetCtrlRect(index);
|
|
|
|
|
|
SetRect( pRt[index] , rect.left, rect.top, rect.right, rect.bottom);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CDnControlData::ParsingRectData( WCHAR* szPosition, RECT& rt )
|
|
|
|
|
|
{
|
|
|
|
|
|
std::vector<int> vecRectPosition;
|
|
|
|
|
|
|
|
|
|
|
|
WCHAR* szResult = wcstok(szPosition, L".");
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
vecRectPosition.push_back(_wtoi(szResult));
|
|
|
|
|
|
szResult = wcstok(NULL, L".");
|
|
|
|
|
|
} while (szResult != NULL);
|
|
|
|
|
|
|
|
|
|
|
|
SetRect(&rt, vecRectPosition[0],vecRectPosition[1],vecRectPosition[2],vecRectPosition[3]);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
RECT CDnControlData::GetCtrlRect(int enumIndex)
|
|
|
|
|
|
{
|
|
|
|
|
|
std::vector<stControlPositionData>::iterator it = m_vecCtrlPosData.begin();
|
|
|
|
|
|
|
|
|
|
|
|
for( ; it != m_vecCtrlPosData.end() ; ++it )
|
|
|
|
|
|
{
|
|
|
|
|
|
if( enumIndex == (*it).nEnum )
|
|
|
|
|
|
{
|
|
|
|
|
|
return (*it).RectPos;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CRect rt(0,0,0,0);
|
|
|
|
|
|
return rt;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CString CDnControlData::GetFilePath( WCHAR* szFilePath )
|
|
|
|
|
|
{
|
|
|
|
|
|
CString szString;
|
|
|
|
|
|
WCHAR szBuff[_MAX_PATH] = { 0 ,};
|
|
|
|
|
|
GetModuleFileName(AfxGetInstanceHandle(), szBuff, sizeof(szBuff));
|
|
|
|
|
|
szString = szBuff;
|
|
|
|
|
|
|
|
|
|
|
|
int nPos = szString.Find(L"Output");
|
|
|
|
|
|
if(nPos == -1)
|
|
|
|
|
|
{
|
|
|
|
|
|
nPos = szString.Find(L"output");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
szString = szString.Left(nPos);
|
|
|
|
|
|
szString = szString + (szFilePath);
|
|
|
|
|
|
|
|
|
|
|
|
return szString;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
WCHAR* CDnControlData::GetMulitiLanguageFilePath()
|
|
|
|
|
|
{
|
|
|
|
|
|
/*
|
|
|
|
|
|
if( m_szLanguageParam == L"FRA" )
|
|
|
|
|
|
else if( m_szLanguageParam == L"ESP" )
|
|
|
|
|
|
else if( m_szLanguageParam == L"GER" )
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
CString szFinalName;
|
|
|
|
|
|
if( !m_szLanguageParam.IsEmpty() )
|
|
|
|
|
|
{
|
|
|
|
|
|
szFinalName += "ControlPositionList_";
|
|
|
|
|
|
szFinalName += m_szLanguageParam;
|
|
|
|
|
|
szFinalName += ".xml";
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
szFinalName += "ControlPositionList.xml";
|
|
|
|
|
|
//szFinalName += m_szLanguageParam;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
CString szString;
|
|
|
|
|
|
WCHAR szBuff[_MAX_PATH] = { 0 ,};
|
|
|
|
|
|
GetModuleFileName(AfxGetInstanceHandle(), szBuff, sizeof(szBuff));
|
|
|
|
|
|
szString = szBuff;
|
|
|
|
|
|
|
|
|
|
|
|
int nPos = szString.Find(L"Output");
|
|
|
|
|
|
szString = szString.Left(nPos);
|
|
|
|
|
|
szString = szString + szFinalName;
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
return szFinalName.GetBuffer(szFinalName.GetLength());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int CDnControlData::GetMulitiLanguageResourceID()
|
|
|
|
|
|
{
|
|
|
|
|
|
int nResultID = -1;
|
|
|
|
|
|
|
|
|
|
|
|
if( m_szLanguageParam == L"FRA" )
|
|
|
|
|
|
{
|
|
|
|
|
|
nResultID = 17003;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if( m_szLanguageParam == L"ESP" )
|
|
|
|
|
|
{
|
|
|
|
|
|
nResultID = 17002;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if( m_szLanguageParam == L"GER" )
|
|
|
|
|
|
{
|
|
|
|
|
|
nResultID = 17004;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
nResultID = 17001;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return nResultID;
|
|
|
|
|
|
}
|