停靠工具栏上的按钮处理问题(多次按下,出现异常)
停靠工具栏上的按钮处理问题(多次按下,出现异常):我的问题是这样的:<BR>我创建了一个停靠工具栏,工具栏上有一个按钮,用来创建文字AcDbText
大致的代码如下:<BR> ads_point ptresult;<BR> //交互输入点<BR> while(acedGetPoint(NULL,"\n输入位置\n",ptresult)==
RTNORM)<BR> {<BR> AcGePoint3d position;<BR> position.set(ptresult,ptresult,0);<BR> AcDbText* pentText = NULL;<BR> pentText = new
AcDbText(position,LPCTSTR(mstr),NULL,10,NULL); <BR> ...<BR> AcDbObjectId entId;<BR> pBlockTableRecord->appendAcDbEntity(entId,
pentText);<BR> ...<BR> }
第一次按下按钮,提示输入点,左键输入点,可以正确的创建文字,<BR>点右键正常退出,<BR>但是如果不点右键(程序没有退出),而再次单击按钮,(重复三次),程序出现
异常,AutoCAD退出,<BR>请教如何解决这个问题
附完整的代码:
//创建text,AcDbText<BR>void CChildDialog::OnButton2() <BR>{<BR> // TODO: Add your control notification handler code here<BR> <BR> CString mstr("hello");<BR> <BR> if(mstr.GetLength()==0)<BR> return;
ads_point ptresult;<BR> while(acedGetPoint(NULL,"\n输入位置\n",ptresult)==
RTNORM)<BR> {<BR> AcGePoint3d position;<BR> position.set(ptresult,ptresult,0);<BR> AcDbText* pentText = NULL;<BR> pentText = new
AcDbText(position,LPCTSTR(mstr),NULL,10,NULL); <BR> <BR>
acDocManager->lockDocument(acDocManager->curDocument());<BR> AcDbBlockTable *pBlockTable;<BR> acdbHostApplicationServices()->workingDatabase()<BR> ->getSymbolTable(pBlockTable,
AcDb::kForRead);<BR> <BR> AcDbBlockTableRecord *pBlockTableRecord;<BR> pBlockTable->getAt(ACDB_MODEL_SPACE,
pBlockTableRecord,<BR> AcDb::kForWrite);<BR> pBlockTable->close();<BR> <BR> AcDbObjectId entId;<BR> pBlockTableRecord->appendAcDbEntity(entId,
pentText);<BR> <BR> pBlockTableRecord->close();<BR> pentText->close();
acDocManager->unlockDocument(acDocManager->curDocument());<BR> }
} 在每一次拾取点之前取消以前命令:
acedPostCommand("CANCELCMD");
...拾取操作
页:
[1]