|
m_pWndMsg = new CWinMsg(m_hDrawOcx);
MxDraw::RegisterFilterWinMsg(m_hDrawOcx,m_pWndMsg);
void CTestDlg::OnDestroy()
{
….
MxDraw::UnRegisterFilterWinMsg(m_hDrawOcx,m_pWndMsg);
…..
}
LRESULT CWinMsg::OnViewLButtonDblClk(UINT nFlags, McGePoint2d point)
{
CPoint ptView((int)point.x,(int)point.y); AcGePoint3d pt = MxDraw::ViewToDocCoord(m_hOcx,ptView);
double dWidth = 1.0;
double dHeight = 1.0;
int iWidth = 6;
MxDraw::GetCursorPickRect(m_hOcx,iWidth);
dWidth = MxDraw::ViewLongToDocCoord(m_hOcx,iWidth);
dHeight = dWidth;
AcDbObjectIdArray aryId;
MxTools::FindEntAtPoint(pt,NULL,dWidth / 2.0,aryId);
if(aryId.length() > 0)
{ AcDbObjectId entId = aryId[0];
AcDbObjectPointer spEnt(entId,AcDb::kForRead);
if(spEnt.openStatus() == Acad::eOk)
{ CString sClassName = spEnt->isA()->name();
AcDbHandle handle;
spEnt->getAcDbHandle(handle);
TCHAR szHandle[256];
handle.getIntoAsciiBuffer(szHandle); CString sLayerName;
{
AcDbObjectPointer spLayerTableRec(spEnt->layerId(),AcDb::kForRead);
if(spLayerTableRec.openStatus() == Acad::eOk)
{
LPCTSTR pszLayerName = NULL;
spLayerTableRec->getName(pszLayerName);
sLayerName = pszLayerName;
}
}
CString sT;
sT.Format(_T("类名:%s,层名:%s,名柄:%s"),sClassName,sLayerName,szHandle);
AfxMessageBox(sT);
MxDraw::SendStringToExecute(m_hOcx,_T("")); return 1;
}
}
return 0;
}
public MouseEventEvent(int lType, double dX, double dY, int lRet)
private void axMxDrawX1_MouseEvent(object sender, AxMxDrawXLib._DMxDrawXEvents_MouseEventEvent e)
{
if(e.lType == 4)
{
MxDrawSelectionSet ss = new MxDrawSelectionSet();
MxDrawResbuf filter = new MxDrawResbuf();
MxDrawPoint point = new MxDrawPoint();
point.x = e.dX;
point.y = e.dY;
ss.SelectAtPoint2(point,filter);
if(ss.Count > 0)
{
MxDrawEntity ent = ss.Item(0);
MessageBox.Show("点击了" + ent.ObjectName + "对象");
/*
if (ent is MxDrawLine)
{
MxDrawLine line = (MxDrawLine)ent;
}
*/
}
e.lRet = 1; axMxDrawX1.SendStringToExecute("");
}
|
|