|
[code]class CLineTypeComboBox : public CAcUiLineTypeComboBox
{
public:
CLineTypeComboBox ();
virtual ~CLineTypeComboBox ();
virtual BOOL OnSelectOther (BOOL isOther2, int curSel, int& newSel);
virtual void OnComboBoxInit ();
};
#include "StdAfx.h"
#include "LineTypeComboBox.h"
CLineTypeComboBox::CLineTypeComboBox()
{
}
CLineTypeComboBox::~CLineTypeComboBox()
{
}
void CLineTypeComboBox::OnComboBoxInit ()
{
Acad::ErrorStatus es;
//用父类初始化
CAcUiLineTypeComboBox::OnComboBoxInit();
std::vector<CString> arrstrLtName;
//如果需要添加新线型,只需定义好新的宏名,在此加入即可...
arrstrLtName.push_back(HH_NEWLINETYPE_001);
arrstrLtName.push_back(HH_NEWLINETYPE_002);
//新建线型,使用户在界面上能够选择到新增的线型
AcDbDatabase *pCurDb=acdbHostApplicationServices()->workingDatabase();
AcDbLinetypeTable *pLinetypeTable;
es = pCurDb->getSymbolTable(pLinetypeTable, AcDb::kForWrite);
if (es != Acad::eOk)
{
return;
}
int i=0;
for (i=0; i<(int)arrstrLtName.size(); i++)
{
CString strLtName = arrstrLtName.at(i);
if (!pLinetypeTable->has(strLtName))
{
AcDbLinetypeTableRecord *pLinetypeRecord = new AcDbLinetypeTableRecord;
pLinetypeRecord->setName(strLtName);
if (i == 0)
{
pLinetypeRecord->setComments(_T("新增线型")+strLtName+_T("—>————<—"));
}
else if (i == 1)
{
pLinetypeRecord->setComments(_T("新增线型")+strLtName+_T("—>>———<<—"));
}
AcDbObjectId idLT = AcDbObjectId::kNull;
es = pLinetypeTable->add(idLT,pLinetypeRecord);
CString LtName = strLtName;
CAcUiLTypeRecord* pLTypeRecord = CreateLTRecord(LtName, idLT);
CAcUiLineTypeComboBox::AddLTypeToControl(pLTypeRecord);
pLinetypeRecord->close();
}
}
pLinetypeTable->close();
};
BOOL CLineTypeComboBox::OnSelectOther(BOOL isOther2, int curSel, int& newSel)
{
return __super::OnSelectOther(isOther2, curSel, newSel);
}[/code] |
|