- 积分
- 572
- 明经币
- 个
- 注册时间
- 2004-12-9
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
停靠工具栏上的按钮处理问题(多次按下,出现异常):
我的问题是这样的: 我创建了一个停靠工具栏,工具栏上有一个按钮,用来创建文字AcDbText
大致的代码如下: ads_point ptresult; //交互输入点 while(acedGetPoint(NULL,"\n输入位置\n",ptresult)==
RTNORM) { AcGePoint3d position; position.set(ptresult[0],ptresult[1],0); AcDbText* pentText = NULL; pentText = new
AcDbText(position,LPCTSTR(mstr),NULL,10,NULL); ... AcDbObjectId entId; pBlockTableRecord->appendAcDbEntity(entId,
pentText); ... }
第一次按下按钮,提示输入点,左键输入点,可以正确的创建文字, 点右键正常退出, 但是如果不点右键(程序没有退出),而再次单击按钮,(重复三次),程序出现
异常,AutoCAD退出, 请教如何解决这个问题
附完整的代码:
//创建text,AcDbText void CChildDialog::OnButton2() { // TODO: Add your control notification handler code here CString mstr("hello"); if(mstr.GetLength()==0) return;
ads_point ptresult; while(acedGetPoint(NULL,"\n输入位置\n",ptresult)==
RTNORM) { AcGePoint3d position; position.set(ptresult[0],ptresult[1],0); AcDbText* pentText = NULL; pentText = new
AcDbText(position,LPCTSTR(mstr),NULL,10,NULL);
acDocManager->lockDocument(acDocManager->curDocument()); AcDbBlockTable *pBlockTable; acdbHostApplicationServices()->workingDatabase() ->getSymbolTable(pBlockTable,
AcDb::kForRead); AcDbBlockTableRecord *pBlockTableRecord; pBlockTable->getAt(ACDB_MODEL_SPACE,
pBlockTableRecord, AcDb::kForWrite); pBlockTable->close(); AcDbObjectId entId; pBlockTableRecord->appendAcDbEntity(entId,
pentText); pBlockTableRecord->close(); pentText->close();
acDocManager->unlockDocument(acDocManager->curDocument()); }
} |
|