提示用户输入一个点坐标.
C++开发|大少爷|2017-07-27 15:57
-
回答:
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; } }