prodevelop 发表于 2010-4-27 00:28:00

activeX中GetBoundingBox的怪问题

<p>用VC++7,VC++8开发activex方式autocad想获得IAcadBlockReference 的 大小,碰到一个怪问题:</p><p>来操作AutoCAD2004的时候,一切正常,来操作AutoCAD2007的时候,却得不到结果:代码如下:</p><p>void GetBlockWidthAndHeight(double* width, double* height, AutoCAD::IAcadBlockReference *pblkRef)<br/>{<br/>&nbsp;&nbsp;&nbsp; VARIANT minPoint, maxPoint;<br/>&nbsp;&nbsp;&nbsp; double* pMaxData = NULL,* pMinData = NULL;<br/>&nbsp;&nbsp;&nbsp; HRESULT hr;<br/>&nbsp;&nbsp;&nbsp; SAFEARRAYBOUND minBound, maxBound;</p><p>&nbsp;&nbsp;&nbsp; VariantInit(&amp;minPoint);<br/>&nbsp;VariantInit(&amp;maxPoint);</p><p>&nbsp;&nbsp;&nbsp; minBound.lLbound = 0;<br/>&nbsp;&nbsp;&nbsp; minBound.cElements = 3;<br/>&nbsp;&nbsp;&nbsp; maxBound.lLbound = 0;<br/>&nbsp;&nbsp;&nbsp; maxBound.cElements = 3;</p><p>&nbsp;&nbsp;&nbsp; minPoint.vt = VT_ARRAY | VT_R8;<br/>&nbsp;&nbsp;&nbsp; maxPoint.vt = VT_ARRAY | VT_R8;<br/>&nbsp;&nbsp;&nbsp; minPoint.parray = SafeArrayCreate(VT_R8, 1, minBound);<br/>&nbsp;&nbsp;&nbsp; maxPoint.parray = SafeArrayCreate(VT_R8, 1, maxBound);</p><p>&nbsp;hr = pblkRef-&gt;GetBoundingBox(&amp;minPoint, &amp;maxPoint);<br/>&nbsp;hr = SafeArrayAccessData(minPoint.parray, (void**)&amp;pMinData);<br/>&nbsp;&nbsp;&nbsp; hr = SafeArrayAccessData(maxPoint.parray, (void**)&amp;pMaxData);</p><p>&nbsp;&nbsp;&nbsp; *width = pMaxData - pMinData;<br/>&nbsp;&nbsp;&nbsp; *height = pMaxData - pMinData;</p><p>&nbsp;hr = SafeArrayUnaccessData(minPoint.parray);<br/>&nbsp;&nbsp;&nbsp; hr = SafeArrayUnaccessData(maxPoint.parray);<br/>}</p><p>操作AutoCAD2007的时候,hr = pblkRef-&gt;GetBoundingBox(&amp;minPoint, &amp;maxPoint); 之后,minPoint和maxPoint均变成:VT_EMPTY了,请帮忙看看什么原因<br/></p><p></p>
页: [1]
查看完整版本: activeX中GetBoundingBox的怪问题