|
2007 提取標題欄屬性問題:
我使用函數ebPaGetHeaderBlock 獲取方式如下:
rtn = ebPaGetHeaderBlock(&SysEntBase,&pBlock,str);
if(rtn != RT_NORMAL){
AfxMessageBox("ebPaGetHeaderBlock失敗");
return RT_FAILED;
}
AfxMessageBox(str);
最後彈出來的對話框竟然是圖框的名稱,而不是標題欄的名稱,感覺非常奇怪。
采用另外一種方式獲取,但是中途CAXA2007會出現內存不可讀,然後終止程序。獲取的方式如下:
CBlock *pTitleBlock = NULL;
pTitleBlock = GetFrameBlock("*HEADER", &SysEntBase);//*HEADER
if (NULL==pTitleBlock){
AfxMessageBox("GetFrameBlock 獲取失敗");
return RT_FAILED;
}
AfxMessageBox(pTitleBlock->name);
CStringArray attrName;
CStringArray attrValue;
ebPaGetHeaderAttArray(pTitleBlock,attrName,attrValue);
str.Format("%d",attrValue.GetSize());
AfxMessageBox(str);
for(int attrCount = 0;attrCount<attrValue.GetSize();attrCount++){
strTemp.Format(attrName.GetAt(attrCount)+"="+attrValue.GetAt(attrCount));
AfxMessageBox(strTemp);
}
另外,我嚐試使用2011來提取屬性,同樣也失敗了,
2011采用CRX方式來獲取,但是缺少方法:
程序如下:
CRxDbBlockTable *pBlockTable;
crxdbHostApplicationServices()->workingDatabase()->getSymbolTable(pBlockTable, CRxDb::kForRead);
CRxDbBlockTableRecord *pBlockTableRecord;
pBlockTable->getAt(CRXDB_MODEL_SPACE, pBlockTableRecord,CRxDb::kForRead);
pBlockTable->close();
//創建塊表記錄遍曆器,用遍曆器遍曆實體
CRxDbBlockTableRecordIterator *pBlockIterator;
CRxDbBlockReference *pAttRef;
pBlockTableRecord->newIterator(pBlockIterator);
for (;!pBlockIterator->done();pBlockIterator->step()){
CRxDbEntity *pEntity;
pBlockIterator->getEntity(pEntity, CRxDb::kForRead);
//crxutPrintf(TEXT("\n%s"),pEntity->desc()->name());
pAttRef = CRxDbBlockReference::cast(pEntity);
if (pAttRef != NULL) {
CRxDbObjectIterator *pBlkRefAttItr=pAttRef->attributeIterator();
for (pBlkRefAttItr->start(); !pBlkRefAttItr->done();pBlkRefAttItr->step())
{
CRxDbObjectId attObjId;
attObjId = pBlkRefAttItr->objectId();
CRxDbAttribute *pAtt = NULL;
CDraft::ErrorStatus es = crxdbOpenObject(pAtt, attObjId, CRxDb::kForRead);
if (es != CDraft::eOk){
crxutPrintf(TEXT("\nFailed to open attribute"));
delete pBlkRefAttItr;
continue;
}
crxutPrintf(TEXT("\n%s"),pAtt->tag());
pAtt->close();
}
}
但是沒有attributeIterator方法,係統裏麵的頭文件注釋掉了,我去掉頭文件的注釋,但是鏈接的時候會出錯。
希望各位知道的兄弟,能夠幫幫我,謝謝。
|
|