www.mxdraw.com
内容索引主面
前一个向上下一个
IMxDrawUiPrPoint 接口

提示用户输入一个点坐标.

IDL
[ object, uuid(EF590D97-DCC9-46ED-A025-E54EE7E91348), dual, nonextensible, helpstring("IMxDrawUiPrPoint interface"), pointer_default(unique) ]
interface IMxDrawUiPrPoint : IMxDrawUiPrBase;

MxDrawUiPrPoint.idl

例如: VB代码.

       Dim getPoint As MxDrawUiPrPoint
       Set getPoint = New MxDrawUiPrPoint
       getPoint.message = "点取一个点 或[闭合(N)/放弃(A)]"
       getPoint.keyWords = "N A"

       Dim basePoint As MxDrawPoint
       Set basePoint = New MxDrawPoint
       basePoint.x = 100
       basePoint.y = 100

       getPoint.basePoint = basePoint
       getPoint.setUseBasePt True

       Dim ret As MCAD_McUiPrStatus
       ret = getPoint.go()

       If ret = MxDrawXLib.mcOk Then
            '输入一个点

            MsgBox getPoint.Value().x
            MsgBox getPoint.Value().y

       ElseIf ret = MxDrawXLib.mcKeyWord Then
            ' 输入了关键字
            MsgBox "关键字"
            MsgBox getPoint.keyWordPicked()
       End If

例如: VC COM调用

        void CTestVc2005Dlg::DoDynDrag()
        {
            long lBak = 0;
            m_ocx.GetSysVarLong(_T("DYNINPUT"),&lBak);
            m_ocx.SetSysVarLong(_T("DYNINPUT"),0);

            MxDrawXLib::IMxDrawUiPrPointPtr getPt;
            getPt.CreateInstance(__uuidof( MxDrawXLib::MxDrawUiPrPoint ));

            IMxDrawUiPrPoint* pGetPt = getPt;
            pGetPt->put_message(_T("点取插入点"));
            if(pGetPt->go() != mcOk)
            {
                m_ocx.SetSysVarLong(_T("DYNINPUT"),lBak);
                return;
            }

            IMxDrawPointPtr frstPt = pGetPt->value();
            if(frstPt == NULL)
            {
                m_ocx.SetSysVarLong(_T("DYNINPUT"),lBak);
                return;
            }



            MxDrawXLib::IMxDrawUiPrPointPtr getSecondPt;
            getSecondPt.CreateInstance(__uuidof( MxDrawXLib::MxDrawUiPrPoint ));

            pGetPt = getSecondPt;

            IMxDrawCustomEntityPtr spDrawData =pGetPt->InitUserDraw(DYNDRAG_DRAW_ID);


            pGetPt->put_message(_T("点取旋转角度"));
            pGetPt->put_basePoint(frstPt);
            pGetPt->setUseBasePt(VARIANT_TRUE);

            spDrawData->SetPoint(_T("pt1"),frstPt);

            CString sBlkFile;
            CString sBlkName(_T("Tree"));
            sBlkFile.Format(_T("%s\Blk\树.dwg"),m_ocx.GetOcxAppPath() );
            short iret = m_ocx.InsertBlock(sBlkFile,_T("Tree"));

            spDrawData->SetString(_T("BlkName"),_T("Tree"));

            if(pGetPt->go() != mcOk)
            {
                m_ocx.SetSysVarLong(_T("DYNINPUT"),lBak);
                return;
            }

            spDrawData->Draw();

            m_ocx.SetSysVarLong(_T("DYNINPUT"),lBak);
        }


        void CTestVc2005Dlg::DynWorldDrawMxdrawxctrl1(double dX, double dY, LPDISPATCH pWorldDraw, LPDISPATCH pData, long* pRet)
        {
            // TODO: 在此处添加消息处理程序代码
            IMxDrawCustomEntityPtr spDrawData;
            pData->QueryInterface(&spDrawData);

            IMxDrawWorldDrawPtr spWordDraw;
            pWorldDraw->QueryInterface(&spWordDraw);

            CString sGuid = spDrawData->Guid;

            *pRet = 0;
            if(sGuid == DYNDRAG_DRAW_ID)
            {
                // 动态插入图块。
                IMxDrawPointPtr firstPt =  spDrawData->GetPoint(_T("pt1"));
                if(firstPt == NULL)
                    return;

                CString sBlkName = spDrawData->GetString(_T("BlkName"));

                MxDrawXLib::IMxDrawPointPtr secondPt;
                secondPt.CreateInstance(__uuidof( MxDrawXLib::MxDrawPoint ));

                secondPt->put_x(dX);
                secondPt->put_y(dY);

                IMxDrawVector3dPtr vec = firstPt->SumVector(secondPt);
                double dAng = vec->Angle();

                _bstr_t psxBlkName = sBlkName.AllocSysString();
                spWordDraw->DrawBlockReference(firstPt->x,firstPt->y,psxBlkName,1.0,dAng * 180.0 / 3.14159265 + 90.0);

                *pRet = 1;
            }

        }
Copyright (c) 2010. All rights reserved.
你认为该帮助怎么样? 发送反馈信息!