www.mxdraw.com
内容索引主面
前一个向上下一个
CMxDrawFilterWinMsgObject 类

该类提供了用户处理控件的窗口消息的功能,用户从该类继承自己的类,重载需要处理的事件函数 调用MxDraw::RegisterFilterWinMsg函数把消息反应器注册到系统中,调用MxDraw::UnRegisterFilterWinMsg反注册

C++
class CMxDrawFilterWinMsgObject;

MxDrawFilterWinMsgObject.h

例如:sampleedit例程中的CWinMsg,注册代码如下

    m_pWndMsg = new CWinMsg(m_hDrawOcx);
    MxDraw::RegisterFilterWinMsg(m_hDrawOcx,m_pWndMsg);
    得到鼠标左键双击事件,读取双击下的实体的ID
    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<AcDbEntity> 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<AcDbLayerTableRecord> 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;
    }
Copyright (c) 2010. All rights reserved.
你认为该帮助怎么样? 发送反馈信息!