649 lines
15 KiB
C++
649 lines
15 KiB
C++
|
|
#include "stdafx.h"
|
|||
|
|
#include "DnControlManager.h"
|
|||
|
|
|
|||
|
|
|
|||
|
|
DnControlManager::DnControlManager()
|
|||
|
|
: m_pTreeList(NULL), m_pCurrentControl(NULL)
|
|||
|
|
{
|
|||
|
|
m_szSaveString.Empty();
|
|||
|
|
m_vecCtrlData.clear();
|
|||
|
|
m_vecTrashPointerList.clear();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
DnControlManager::~DnControlManager()
|
|||
|
|
{
|
|||
|
|
if(!m_vecTrashPointerList.empty())
|
|||
|
|
{
|
|||
|
|
std::vector<char*>::iterator it = m_vecTrashPointerList.begin();
|
|||
|
|
|
|||
|
|
for( ; it != m_vecTrashPointerList.end() ; ++it )
|
|||
|
|
{
|
|||
|
|
delete [] ((*it));
|
|||
|
|
(*it) = NULL;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(!m_vecCtrlData.empty())
|
|||
|
|
{
|
|||
|
|
std::vector<stNewControlData>::iterator it = m_vecCtrlData.begin();
|
|||
|
|
|
|||
|
|
for( ; it != m_vecCtrlData.end() ; ++it )
|
|||
|
|
{
|
|||
|
|
SAFE_DELETE((*it).m_WndPT);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
CWnd* DnControlManager::GetCtrl(CString szString)
|
|||
|
|
{
|
|||
|
|
CWnd* res = NULL;
|
|||
|
|
|
|||
|
|
std::vector<stNewControlData>::iterator it = m_vecCtrlData.begin();
|
|||
|
|
|
|||
|
|
for( ; it != m_vecCtrlData.end() ; ++it )
|
|||
|
|
{
|
|||
|
|
if( (*it).m_szName.Compare(szString) == 0 )
|
|||
|
|
{
|
|||
|
|
res = (*it).m_WndPT;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return res;
|
|||
|
|
}
|
|||
|
|
int DnControlManager::GetEnum(CString szString)
|
|||
|
|
{
|
|||
|
|
int nEnum = -1;
|
|||
|
|
|
|||
|
|
std::vector<stNewControlData>::iterator it = m_vecCtrlData.begin();
|
|||
|
|
|
|||
|
|
for( ; it != m_vecCtrlData.end() ; ++it )
|
|||
|
|
{
|
|||
|
|
if( (*it).m_szName.Compare(szString) == 0 )
|
|||
|
|
{
|
|||
|
|
nEnum = (*it).m_nEnumValue;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return nEnum;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
CWnd* DnControlManager::CheckCollision(POINT pt, int& nEnum)
|
|||
|
|
{
|
|||
|
|
if( m_vecCtrlData.empty() )
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD>Ͱ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>..
|
|||
|
|
return NULL;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
RECT controlRect;
|
|||
|
|
CWnd* control = NULL;
|
|||
|
|
std::vector<stNewControlData>::iterator it = m_vecCtrlData.begin();
|
|||
|
|
|
|||
|
|
for( ; it != m_vecCtrlData.end() ; ++it )
|
|||
|
|
{
|
|||
|
|
control = (*it).m_WndPT;
|
|||
|
|
|
|||
|
|
if(control != NULL)
|
|||
|
|
{
|
|||
|
|
control->GetWindowRect(&controlRect);
|
|||
|
|
if( PtInRect(&controlRect, pt) )
|
|||
|
|
{
|
|||
|
|
nEnum = (*it).m_nEnumValue;
|
|||
|
|
return control;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return NULL;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
HBITMAP DnControlManager::MakeBitmap(CString &szFilePath)
|
|||
|
|
{
|
|||
|
|
TCHAR szFilter[] = _T("Image Files (*.bmp, *.jpg, *.png) | *.bmp;*.jpg;*.png||");
|
|||
|
|
CFileDialog dlg(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter);
|
|||
|
|
if( dlg.DoModal() == IDOK )
|
|||
|
|
{
|
|||
|
|
CxImage xImage;
|
|||
|
|
CString szPath = dlg.GetPathName();
|
|||
|
|
CString szFileName = dlg.GetFileName();
|
|||
|
|
szFilePath = dlg.GetFileName();
|
|||
|
|
|
|||
|
|
|
|||
|
|
// xml<6D><6C><EFBFBD><EFBFBD> <20>̹<EFBFBD><CCB9><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ΰ<EFBFBD> "<22><><EFBFBD><EFBFBD><EFBFBD≯<EFBFBD>"<22><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Ǿ<EFBFBD><C7BE>ִ<EFBFBD>.
|
|||
|
|
// <20><><EFBFBD>δ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>. <20><>ǻ<EFBFBD><EFBFBD><CDB8><EFBFBD> <20><><EFBFBD>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ġ<EFBFBD><C4A1> Ʋ<><C6B2><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>..
|
|||
|
|
// <20>켱 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Ǵ<EFBFBD> <20>̹<EFBFBD><CCB9><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>θ<EFBFBD> <20>̿<EFBFBD><CCBF>ؼ<EFBFBD>, <20><><EFBFBD><EFBFBD> <20>ҷ<EFBFBD><D2B7><EFBFBD> <20>̹<EFBFBD><CCB9><EFBFBD><EFBFBD><EFBFBD> test<73><74><EFBFBD><EFBFBD>, kor<6F><72><EFBFBD><EFBFBD> Ȯ<>ο<EFBFBD><CEBF><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>.
|
|||
|
|
m_RootPath = szPath;
|
|||
|
|
|
|||
|
|
//--------------------------------------------------
|
|||
|
|
// bmp<6D><70><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ҷ<EFBFBD><D2B7>Դٸ<D4B4> <20><><EFBFBD><EFBFBD>ó<EFBFBD><C3B3><EFBFBD>Ѵ<EFBFBD>.
|
|||
|
|
// CxImage<67><65><EFBFBD><EFBFBD> bmp<6D><70> <20>ε<EFBFBD><CEB5><EFBFBD> <20>ȵȴ<C8B5>. <20><><EFBFBD>̷<EFBFBD><CCB7><EFBFBD>.....
|
|||
|
|
//--------------------------------------------------
|
|||
|
|
int nFindResult = szFileName.Find(L"bmp");
|
|||
|
|
if(nFindResult != -1)
|
|||
|
|
{
|
|||
|
|
HBITMAP bimtmap = (HBITMAP)LoadImage(NULL , szPath, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
|
|||
|
|
return bimtmap;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//--------------------------------------------------
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>̹<EFBFBD><CCB9><EFBFBD> ó<><C3B3>.
|
|||
|
|
//--------------------------------------------------
|
|||
|
|
if( !xImage.Load(szPath) )
|
|||
|
|
{
|
|||
|
|
return NULL;
|
|||
|
|
}
|
|||
|
|
HBITMAP hBmp = xImage.MakeBitmap();
|
|||
|
|
|
|||
|
|
return hBmp;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return NULL;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
HRESULT DnControlManager::Save()
|
|||
|
|
{
|
|||
|
|
TCHAR szFilter[] = _T("XML Files (*.xml, *.XML) | *.xml;*.XML ||");
|
|||
|
|
TCHAR szDefaultName[] = _T("ControlPositionList.xml");
|
|||
|
|
|
|||
|
|
CFileDialog dlg(FALSE, NULL, szDefaultName, OFN_OVERWRITEPROMPT, szFilter);
|
|||
|
|
|
|||
|
|
CString szPathName;
|
|||
|
|
CString szFileName;
|
|||
|
|
|
|||
|
|
if( dlg.DoModal() == IDOK )
|
|||
|
|
{
|
|||
|
|
szPathName = dlg.GetPathName();
|
|||
|
|
szFileName = dlg.GetFileName();
|
|||
|
|
|
|||
|
|
CXMLCreater aParser;
|
|||
|
|
char szValue[100] = { 0 , };
|
|||
|
|
char szRectbuff[100] = { 0 , };
|
|||
|
|
char szImageResource[100]= { 0 , };
|
|||
|
|
char szName[100] = { 0 , };
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD> <20≯<EFBFBD> <20><><EFBFBD><EFBFBD>.
|
|||
|
|
int nFindSpot = szPathName.Find(L".");
|
|||
|
|
if(nFindSpot == -1)
|
|||
|
|
{
|
|||
|
|
// Ȯ<><C8AE><EFBFBD>ڰ<EFBFBD> <20><><EFBFBD><EFBFBD>.
|
|||
|
|
szPathName+=".xml";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
aParser.Init(StringToChar(szFileName), StringToChar(szPathName));
|
|||
|
|
aParser.AddElement("document",true);
|
|||
|
|
|
|||
|
|
|
|||
|
|
std::vector<stNewControlData>::iterator it = m_vecCtrlData.begin();
|
|||
|
|
for( ; it != m_vecCtrlData.end() ; ++it )
|
|||
|
|
{
|
|||
|
|
WINDOWPLACEMENT place;
|
|||
|
|
(*it).m_WndPT->GetWindowPlacement(&place);
|
|||
|
|
|
|||
|
|
sprintf(szRectbuff, "%d.%d.%d.%d", place.rcNormalPosition.left , place.rcNormalPosition.top,
|
|||
|
|
place.rcNormalPosition.right, place.rcNormalPosition.bottom );
|
|||
|
|
|
|||
|
|
aParser.AddElement("ContrlListData");
|
|||
|
|
|
|||
|
|
aParser.AddAttribute("RectPos", szRectbuff);
|
|||
|
|
aParser.AddAttribute("ImgPath", StringToChar((*it).m_szResourceFileName));
|
|||
|
|
aParser.AddAttribute("Type", (*it).m_nType);
|
|||
|
|
aParser.AddAttribute("Name", StringToChar((*it).m_szName));
|
|||
|
|
aParser.AddAttribute("Enum", (*it).m_nEnumValue);
|
|||
|
|
}
|
|||
|
|
aParser.Create();
|
|||
|
|
|
|||
|
|
return S_OK;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return E_FAIL;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
HRESULT DnControlManager::Load()
|
|||
|
|
{
|
|||
|
|
// <20>ε<EFBFBD><CEB5>ϱ<EFBFBD><CFB1><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>.
|
|||
|
|
ResetControlData();
|
|||
|
|
|
|||
|
|
TCHAR szFilter[] = _T("XML Files (*.xml) | *.XML||");
|
|||
|
|
TCHAR szDefaultName[] = _T("ControlPositionList.xml");
|
|||
|
|
CFileDialog dlg(TRUE, NULL, szDefaultName, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_FILEMUSTEXIST, szFilter);
|
|||
|
|
if( dlg.DoModal() == IDCANCEL )
|
|||
|
|
{
|
|||
|
|
return NULL;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
CString szFullPath = dlg.GetPathName();
|
|||
|
|
CString szFileName = dlg.GetFileName();
|
|||
|
|
|
|||
|
|
CXMLParser aParser;
|
|||
|
|
{
|
|||
|
|
USES_CONVERSION;
|
|||
|
|
|
|||
|
|
WCHAR szRectPos[1024] = { '\0', };
|
|||
|
|
WCHAR szImgPath[1024] = { '\0', };
|
|||
|
|
WCHAR szType[1024] = { '\0', };
|
|||
|
|
WCHAR szName[1024] = { '\0', };
|
|||
|
|
WCHAR szEnum[1024] = { '\0', };
|
|||
|
|
|
|||
|
|
if( !aParser.Open(StringToChar(szFullPath)) )
|
|||
|
|
{
|
|||
|
|
return E_FAIL;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if( aParser.FirstChildElement("document",true) )
|
|||
|
|
{
|
|||
|
|
do
|
|||
|
|
{
|
|||
|
|
if( aParser.FirstChildElement("ContrlListData",false) )
|
|||
|
|
{
|
|||
|
|
do
|
|||
|
|
{
|
|||
|
|
::wcsncpy_s( szRectPos, _countof(szRectPos),aParser.GetAttribute("RectPos"),_countof(szRectPos) );
|
|||
|
|
::wcsncpy_s( szImgPath, _countof(szImgPath),aParser.GetAttribute("ImgPath"),_countof(szImgPath) );
|
|||
|
|
::wcsncpy_s( szType, _countof(szType), aParser.GetAttribute("Type"), _countof(szType) );
|
|||
|
|
::wcsncpy_s( szName, _countof(szName), aParser.GetAttribute("Name"), _countof(szName) );
|
|||
|
|
::wcsncpy_s( szEnum, _countof(szEnum), aParser.GetAttribute("Enum"), _countof(szEnum) );
|
|||
|
|
|
|||
|
|
// <20><>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD> <20><>ġ <20><><EFBFBD><EFBFBD>.
|
|||
|
|
if( !SetControlPosition(szRectPos, szImgPath, szName, _wtoi(szType), _wtoi(szEnum)))
|
|||
|
|
{
|
|||
|
|
return E_FAIL;
|
|||
|
|
}
|
|||
|
|
} while(aParser.NextSiblingElement("ContrlListData"));
|
|||
|
|
}
|
|||
|
|
} while(aParser.NextSiblingElement("document"));
|
|||
|
|
|
|||
|
|
} // end of document
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
m_pTreeList->SortChildren(m_hBtnItem);
|
|||
|
|
m_pTreeList->SortChildren(m_hTextItem);
|
|||
|
|
m_pTreeList->SortChildren(m_hProgressItem);
|
|||
|
|
m_pTreeList->SortChildren(m_hCheckBoxItem);
|
|||
|
|
|
|||
|
|
return S_OK;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
bool DnControlManager::SetControlPosition(WCHAR* szRectPos, WCHAR* szImgPath, WCHAR* szName, int nType, int nEnum)
|
|||
|
|
{
|
|||
|
|
//-----------------------------------
|
|||
|
|
// 1. Rect<63><74> <20>и<EFBFBD><D0B8>ϱ<EFBFBD>.
|
|||
|
|
//-----------------------------------
|
|||
|
|
RECT rect;
|
|||
|
|
std::vector<int> vecRectPosition;
|
|||
|
|
WCHAR* szResult = wcstok(szRectPos, L".");
|
|||
|
|
do
|
|||
|
|
{
|
|||
|
|
vecRectPosition.push_back(_wtoi(szResult));
|
|||
|
|
szResult = wcstok(NULL, L".");
|
|||
|
|
}while (szResult != NULL);
|
|||
|
|
SetRect(&rect, vecRectPosition[0],vecRectPosition[1],vecRectPosition[2],vecRectPosition[3]);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>.
|
|||
|
|
stNewControlData tempData;
|
|||
|
|
tempData.m_RectPos = rect;
|
|||
|
|
tempData.m_nType = nType;
|
|||
|
|
tempData.m_szName = szName;
|
|||
|
|
tempData.m_nEnumValue = nEnum;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD>.
|
|||
|
|
if( wcslen(szImgPath) )
|
|||
|
|
{
|
|||
|
|
// <20>̹<EFBFBD><CCB9><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>.
|
|||
|
|
CHAR DumpFileName[MAX_PATH];
|
|||
|
|
::GetModuleFileNameA(NULL, DumpFileName, MAX_PATH);
|
|||
|
|
|
|||
|
|
CString tempStr = m_RootPath;
|
|||
|
|
tempStr.MakeLower();
|
|||
|
|
|
|||
|
|
CT2CA pszConvert(tempStr);
|
|||
|
|
std::string szPath = pszConvert;
|
|||
|
|
|
|||
|
|
int nOffset = szPath.rfind("\\");
|
|||
|
|
if(std::string::npos != nOffset)
|
|||
|
|
{
|
|||
|
|
szPath.erase(nOffset);
|
|||
|
|
|
|||
|
|
USES_CONVERSION;
|
|||
|
|
|
|||
|
|
std::wstring wszPath( A2W(szPath.c_str()) );
|
|||
|
|
|
|||
|
|
WCHAR szTempPath[_MAX_PATH] = { 0 , };
|
|||
|
|
wsprintfW(szTempPath, _T("\\%s"), szImgPath);
|
|||
|
|
wszPath += szTempPath;
|
|||
|
|
|
|||
|
|
tempData.m_szResourceFileName = wszPath.c_str();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
tempData.m_szResourceFileName = szImgPath;
|
|||
|
|
//tempData.m_szResourceFileName = szImgPath;
|
|||
|
|
|
|||
|
|
m_vecCtrlData.push_back(tempData);
|
|||
|
|
|
|||
|
|
|
|||
|
|
// Ʈ<><C6AE> <20><>Ʈ<EFBFBD>ѿ<EFBFBD> <20>μ<EFBFBD>Ʈ.
|
|||
|
|
HTREEITEM hItem = GetParentItem(nType);
|
|||
|
|
HTREEITEM CurrentItem = m_pTreeList->InsertItem(tempData.m_szName, hItem, TVI_LAST);
|
|||
|
|
m_pTreeList->SetCheck(CurrentItem, true);
|
|||
|
|
m_pTreeList->Expand(hItem, TVE_EXPAND);
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
char* DnControlManager::StringToChar( CString& str )
|
|||
|
|
{
|
|||
|
|
long len = str.GetLength();
|
|||
|
|
len = len * 2;
|
|||
|
|
char* szTemp = new char[len+1];
|
|||
|
|
|
|||
|
|
memset(szTemp, 0, len + 1);
|
|||
|
|
USES_CONVERSION;
|
|||
|
|
strcpy(szTemp, T2A(str));
|
|||
|
|
|
|||
|
|
m_vecTrashPointerList.push_back(szTemp);
|
|||
|
|
|
|||
|
|
return szTemp;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
bool DnControlManager::SetResourceFilePath( CString szIndex , CString szFilePath )
|
|||
|
|
{
|
|||
|
|
std::vector<stNewControlData>::iterator it = m_vecCtrlData.begin();
|
|||
|
|
|
|||
|
|
for( ; it != m_vecCtrlData.end() ; ++it )
|
|||
|
|
{
|
|||
|
|
if( (*it).m_szName.Compare(szIndex) == 0 )
|
|||
|
|
{
|
|||
|
|
(*it).m_szResourceFileName = szFilePath;
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
bool DnControlManager::SetStaticText( CString szIndex , CString szStaticText )
|
|||
|
|
{
|
|||
|
|
std::vector<stNewControlData>::iterator it = m_vecCtrlData.begin();
|
|||
|
|
|
|||
|
|
for( ; it != m_vecCtrlData.end() ; ++it )
|
|||
|
|
{
|
|||
|
|
if( (*it).m_szName.Compare(szIndex) == 0 )
|
|||
|
|
{
|
|||
|
|
(*it).m_szName = szStaticText;
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
bool DnControlManager::ReleaseResourceFilePath( CString szIndex )
|
|||
|
|
{
|
|||
|
|
std::vector<stNewControlData>::iterator it = m_vecCtrlData.begin();
|
|||
|
|
|
|||
|
|
for( ; it != m_vecCtrlData.end() ; ++it )
|
|||
|
|
{
|
|||
|
|
if( (*it).m_szName.Compare(szIndex) == 0 )
|
|||
|
|
{
|
|||
|
|
(*it).m_szResourceFileName = "";
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
bool DnControlManager::SetCheckBox( CString szIndex, int nCheck)
|
|||
|
|
{
|
|||
|
|
/*std::vector<stNewControlData>::iterator it = m_vecCtrlData.begin();
|
|||
|
|
|
|||
|
|
for( ; it != m_vecCtrlData.end() ; ++it )
|
|||
|
|
{
|
|||
|
|
if( (*it).szName.Compare(szIndex) == 0 )
|
|||
|
|
{
|
|||
|
|
(*it).nIsVisible = nCheck;
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
}*/
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
HBITMAP DnControlManager::GetBitmap( _CTRL_IT it )
|
|||
|
|
{
|
|||
|
|
HBITMAP HBitmap = NULL;
|
|||
|
|
|
|||
|
|
if(! (*it).m_szResourceFileName.IsEmpty() )
|
|||
|
|
{
|
|||
|
|
CString szFilePath( (*it).m_szResourceFileName );
|
|||
|
|
|
|||
|
|
|
|||
|
|
int nFindResult = szFilePath.Find(L"bmp");
|
|||
|
|
if(nFindResult != -1)
|
|||
|
|
{
|
|||
|
|
// Ȯ<><C8AE><EFBFBD>ڰ<EFBFBD> <20><>Ʈ<EFBFBD><C6AE><EFBFBD≯<EFBFBD>
|
|||
|
|
HBitmap = (HBITMAP)LoadImage(NULL , szFilePath, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// <20>ٸ<EFBFBD> Ȯ<><C8AE><EFBFBD>ڵ<EFBFBD>.
|
|||
|
|
CxImage xImage;
|
|||
|
|
if( !xImage.Load(szFilePath) )
|
|||
|
|
{
|
|||
|
|
szFilePath.Format(_T("<EFBFBD><EFBFBD><EFBFBD>Ϸε忡 <20><><EFBFBD><EFBFBD><EFBFBD>߽<EFBFBD><DFBD>ϴ<EFBFBD>.\n%s"), szFilePath);
|
|||
|
|
AfxMessageBox(szFilePath);
|
|||
|
|
return NULL;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
HBitmap = xImage.MakeBitmap();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
BITMAP bmp = { 0 };
|
|||
|
|
GetObject( HBitmap, sizeof(BITMAP), &bmp );
|
|||
|
|
CButton* pBtn = static_cast<CButton*> ((*it).m_WndPT);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return HBitmap;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//_CTRL_IT DnControlManager::GetVecIterator( CString szString )
|
|||
|
|
bool DnControlManager::GetVecIterator( CString szString, _CTRL_IT &it)
|
|||
|
|
{
|
|||
|
|
it = std::find(m_vecCtrlData.begin(),m_vecCtrlData.end(),szString);
|
|||
|
|
if( it != m_vecCtrlData.end() )
|
|||
|
|
{
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
HTREEITEM DnControlManager::GetParentItem(int nType)
|
|||
|
|
{
|
|||
|
|
switch(nType)
|
|||
|
|
{
|
|||
|
|
case _TEXT:
|
|||
|
|
return m_hTextItem;
|
|||
|
|
|
|||
|
|
case _BUTTON:
|
|||
|
|
return m_hBtnItem;
|
|||
|
|
|
|||
|
|
case _PROGRESS_BAR:
|
|||
|
|
return m_hProgressItem;
|
|||
|
|
|
|||
|
|
case _CHECK_BOX:
|
|||
|
|
return m_hCheckBoxItem;
|
|||
|
|
|
|||
|
|
default:
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return m_hRootItem;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
void DnControlManager::CreateControlData(CDialog* pParent)
|
|||
|
|
{
|
|||
|
|
HBITMAP hBitmap;
|
|||
|
|
CButton *pButton;
|
|||
|
|
CStatic *pText;
|
|||
|
|
CButton *pCheckBox;
|
|||
|
|
|
|||
|
|
std::vector<stNewControlData>::iterator it = m_vecCtrlData.begin();
|
|||
|
|
for( ; it != m_vecCtrlData.end() ; ++it )
|
|||
|
|
{
|
|||
|
|
switch((*it).m_nType)
|
|||
|
|
{
|
|||
|
|
case _BUTTON:
|
|||
|
|
pButton = new CButton;
|
|||
|
|
pButton->Create((*it).m_szName, WS_VISIBLE | WS_CHILD | LBS_NOTIFY | BS_BITMAP , (*it).m_RectPos, pParent, 0);
|
|||
|
|
pButton->EnableWindow(false);
|
|||
|
|
pButton->ShowWindow(SW_SHOW);
|
|||
|
|
hBitmap = GetBitmap(it);
|
|||
|
|
if(hBitmap)
|
|||
|
|
{
|
|||
|
|
pButton->SetBitmap(hBitmap);
|
|||
|
|
}
|
|||
|
|
(*it).m_WndPT = pButton;
|
|||
|
|
break;
|
|||
|
|
|
|||
|
|
case _TEXT:
|
|||
|
|
pText = new CStatic;
|
|||
|
|
pText->Create((*it).m_szName, WS_VISIBLE | SS_LEFTNOWORDWRAP , (*it).m_RectPos, pParent, 0);
|
|||
|
|
pText->EnableWindow(TRUE);
|
|||
|
|
pText->ShowWindow(SW_SHOW);
|
|||
|
|
(*it).m_WndPT = pText;
|
|||
|
|
break;
|
|||
|
|
|
|||
|
|
case _PROGRESS_BAR:
|
|||
|
|
pButton = new CButton;
|
|||
|
|
pButton->Create((*it).m_szName, WS_VISIBLE | WS_CHILD | LBS_NOTIFY, (*it).m_RectPos, pParent, 0);
|
|||
|
|
pButton->EnableWindow(false);
|
|||
|
|
pButton->ShowWindow(SW_SHOW);
|
|||
|
|
(*it).m_WndPT = pButton;
|
|||
|
|
break;
|
|||
|
|
|
|||
|
|
case _CHECK_BOX:
|
|||
|
|
pCheckBox = new CButton;
|
|||
|
|
pCheckBox->Create(L"", WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX | BS_LEFTTEXT , (*it).m_RectPos, pParent, 0);
|
|||
|
|
pCheckBox->EnableWindow(false);
|
|||
|
|
pCheckBox->ShowWindow(SW_SHOW);
|
|||
|
|
(*it).m_WndPT = pCheckBox;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void DnControlManager::ResetControlData()
|
|||
|
|
{
|
|||
|
|
BOOL bFlag = m_pTreeList->DeleteAllItems();
|
|||
|
|
m_hRootItem = m_pTreeList->InsertItem(_T("<EFBFBD><EFBFBD>Ʈ<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>"), TVI_ROOT, TVI_LAST);
|
|||
|
|
|
|||
|
|
m_hBtnItem = m_pTreeList->InsertItem(_T("BUTTONS"), m_hRootItem, TVI_LAST);
|
|||
|
|
m_hTextItem = m_pTreeList->InsertItem(_T("STATIC_TEXT"), m_hRootItem, TVI_LAST);
|
|||
|
|
m_hProgressItem = m_pTreeList->InsertItem(_T("PROGRESSBAR"), m_hRootItem, TVI_LAST);
|
|||
|
|
m_hCheckBoxItem = m_pTreeList->InsertItem(_T("CHECK_BOX"), m_hRootItem, TVI_LAST);
|
|||
|
|
|
|||
|
|
m_pTreeList->Expand(m_hRootItem, TVE_EXPAND);
|
|||
|
|
m_pTreeList->Expand(m_hBtnItem, TVE_EXPAND);
|
|||
|
|
m_pTreeList->Expand(m_hTextItem, TVE_EXPAND);
|
|||
|
|
m_pTreeList->Expand(m_hProgressItem,TVE_EXPAND);
|
|||
|
|
m_pTreeList->Expand(m_hCheckBoxItem,TVE_EXPAND);
|
|||
|
|
|
|||
|
|
|
|||
|
|
if(!m_vecTrashPointerList.empty())
|
|||
|
|
{
|
|||
|
|
std::vector<char*>::iterator it = m_vecTrashPointerList.begin();
|
|||
|
|
|
|||
|
|
for( ; it != m_vecTrashPointerList.end() ; ++it )
|
|||
|
|
{
|
|||
|
|
delete [] ((*it));
|
|||
|
|
(*it) = NULL;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
m_vecTrashPointerList.erase(m_vecTrashPointerList.begin(), m_vecTrashPointerList.end());
|
|||
|
|
|
|||
|
|
|
|||
|
|
if(!m_vecCtrlData.empty())
|
|||
|
|
{
|
|||
|
|
std::vector<stNewControlData>::iterator it = m_vecCtrlData.begin();
|
|||
|
|
|
|||
|
|
for( ; it != m_vecCtrlData.end() ; ++it )
|
|||
|
|
{
|
|||
|
|
SAFE_DELETE((*it).m_WndPT);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
m_vecCtrlData.erase(m_vecCtrlData.begin(), m_vecCtrlData.end());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
bool DnControlManager::DeleteCtrl(CString szName, HTREEITEM treeItem)
|
|||
|
|
{
|
|||
|
|
if(m_vecCtrlData.empty())
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
std::vector<stNewControlData>::iterator it = m_vecCtrlData.begin();
|
|||
|
|
for( ; it != m_vecCtrlData.end() ; )
|
|||
|
|
{
|
|||
|
|
if( (*it).m_szName.Compare(szName) == 0 )
|
|||
|
|
{
|
|||
|
|
SAFE_DELETE((*it).m_WndPT); // <20><>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD>.
|
|||
|
|
m_pTreeList->DeleteItem(treeItem); // <20><><EFBFBD><EFBFBD>Ʈ <20><>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD>.
|
|||
|
|
it = m_vecCtrlData.erase(it); // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>.
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
++it;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
bool DnControlManager::IsLockObject(int nEnumID)
|
|||
|
|
{
|
|||
|
|
if(!m_vecLockObjects.empty() || nEnumID != -1)
|
|||
|
|
{
|
|||
|
|
std::vector<int>::iterator it = m_vecLockObjects.begin();
|
|||
|
|
for( ; it != m_vecLockObjects.end() ; ++it )
|
|||
|
|
{
|
|||
|
|
if( (*it) == nEnumID )
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void DnControlManager::SetLockObject(int nEnumID)
|
|||
|
|
{
|
|||
|
|
// <20>ߺ<EFBFBD> pushback <20><><EFBFBD><EFBFBD>.
|
|||
|
|
bool bIsOverLap = false;
|
|||
|
|
|
|||
|
|
std::vector<int>::iterator it = m_vecLockObjects.begin();
|
|||
|
|
for( ; it != m_vecLockObjects.end() ; ++it )
|
|||
|
|
{
|
|||
|
|
if( (*it) == nEnumID )
|
|||
|
|
bIsOverLap = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(!bIsOverLap)
|
|||
|
|
m_vecLockObjects.push_back(nEnumID);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void DnControlManager::SetUnLockObject(int nEnumID)
|
|||
|
|
{
|
|||
|
|
if(!m_vecLockObjects.empty())
|
|||
|
|
{
|
|||
|
|
std::vector<int>::iterator it = remove(m_vecLockObjects.begin(), m_vecLockObjects.end(), nEnumID);
|
|||
|
|
m_vecLockObjects.erase(it);
|
|||
|
|
}
|
|||
|
|
}
|