ObjectARX 实体双击之消息截获

高版本的双击参杂了cui自定义双击处理,继承AcDbDoubleClickEdit的双击协议可能无效,因此可以尝试从消息处理

代码

bool filterMouse(MSG *pMsg)
{
	if( pMsg->message == WM_LBUTTONDBLCLK )
	{
		ads_name ss;
		if(RTNORM != acedSSGet(_T("I"),NULL,NULL,NULL,ss))
		{
			return false;
		}
		ads_name ent;
		acedSSName(ss,0,ent);
		acedSSFree(ss);
		AcDbObjectId objId;
		acdbGetObjectId(objId,ent);
		CString strDxf= objId.objectClass()->dxfName();
		if (strDxf == _T("MTEXT"))
		{
			//acutPrintf(_T("\n自定义处理"));
			bool bIsMtext=false;
			acDocManager->lockDocument(curDoc());
			AcDbObjectPointer<AcDbMText>pMtext(objId,AcDb::kForRead);
			if(Acad::eOk == pMtext.openStatus())
			{
				if (pMtext->colorIndex() == 1)
				{
					bIsMtext=true;
					pMtext->close();
				}
			}
			acDocManager->unlockDocument(curDoc());
			if (bIsMtext)
			{
				acDocManager->sendStringToExecute(curDoc(),_T("_properties "));
				//截断消息
				return true;
			}			
		}		
	}
	//消息继续传递
	return false;
}

注册

acedRegisterFilterWinMsg(filterMouse);

卸载

acedRemoveFilterWinMsg(filterMouse);

posted @ 2022-01-14 13:15  edata  阅读(481)  评论(0编辑  收藏  举报