86 lines
1.5 KiB
C++
86 lines
1.5 KiB
C++
#include "stdafx.h"
|
|
#include "TextStyleComboBox.h"
|
|
#include "EarThwormDef.h"
|
|
|
|
|
|
CTextStyleComboBox::CTextStyleComboBox()
|
|
{
|
|
|
|
}
|
|
|
|
CTextStyleComboBox::~CTextStyleComboBox()
|
|
{
|
|
|
|
}
|
|
|
|
void CTextStyleComboBox::init()
|
|
{
|
|
if (!IsWindow(GetSafeHwnd())) return;
|
|
if (!acdbCurDwg()) return;
|
|
|
|
ResetContent();
|
|
|
|
AcDbTextStyleTable *pTextTable;
|
|
acdbCurDwg()->getTextStyleTable(pTextTable, AcDb::kForRead);
|
|
if (!pTextTable) return;
|
|
AcDbTextStyleTableIterator *pIt(NULL);
|
|
pTextTable->newIterator(pIt);
|
|
if (!pIt)
|
|
{
|
|
pTextTable->close();
|
|
return;
|
|
}
|
|
|
|
int i(0);
|
|
TCHAR *pszName = NULL;
|
|
for (; !pIt->done(); pIt->step())
|
|
{
|
|
AcDbTextStyleTableRecord *pRec(NULL);
|
|
pIt->getRecord(pRec, AcDb::kForRead);
|
|
if (pRec->getName(pszName) == Acad::eOk)
|
|
{
|
|
if (_tcslen(pszName) > 0 )
|
|
{
|
|
AddString(pszName);
|
|
SetItemData(i, pRec->objectId().asOldId());
|
|
++i;
|
|
acutDelString(pszName);
|
|
pszName = NULL;
|
|
}
|
|
pRec->close();
|
|
}
|
|
}
|
|
|
|
//AddString(_T("其它..."));
|
|
|
|
if (GetCount())
|
|
SetCurSel(0);
|
|
|
|
DELETE_PTR(pIt);
|
|
pTextTable->close();
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CTextStyleComboBox, CComboBox)
|
|
ON_CONTROL_REFLECT(CBN_SELCHANGE, &CTextStyleComboBox::OnCbnSelchange)
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
void CTextStyleComboBox::OnCbnSelchange()
|
|
{
|
|
// int idx = GetCurSel();
|
|
// if (idx == GetCount() - 1) // 最后
|
|
// {
|
|
// init();
|
|
// }
|
|
}
|
|
|
|
AcDbObjectId CTextStyleComboBox::getTextStyleID()
|
|
{
|
|
int idx = GetCurSel();
|
|
if (idx == -1) return AcDbObjectId::kNull;
|
|
DWORD_PTR dw = GetItemData(idx);
|
|
AcDbObjectId id(AcDbObjectId::kNull);
|
|
id.setFromOldId(dw);
|
|
return id;
|
|
}
|