mdlDisplayPath_getInfoString


mdlDisplayPath_getInfoString函数能取得光标悬停到某个元素上时显示的提示信息。如下图中所示的Solid Level:(none) (Default):

在MicroStation V8i的SDK帮助文档中对该函数的说明有如下一段文字:

You can use the MAX_DISPLAYPATH_INFO_STRING constant to define the size of the output buffer. 

意思是说,我们可以将返回值outString的大小指定为MAX_DISPLAYPATH_INFO_STRING。但当我们真正这样做时,该函数调用完后会导致MicroStation崩溃。经研究发现,该值被定义为了256,这是MicroStation V8 2004时代的定义,到了V8i,该缓冲区内部被增大到了4096,仍然用256导致内存溢出从而MicroStation崩溃。正确的示例代码如下:

void extractInfoString()
    {
    ElementRef   elRef = dgnCache_findElemByID(mdlModelRef_getCache(ACTIVEMODEL), 1501);
    if (NULL == elRef)
        return;
    DisplayPathP path = mdlDisplayPath_new(elRef, ACTIVEMODEL);
    MSWChar infoStr[4096];  // Can't use the MAX_DISPLAYPATH_INFO_STRING in doc, which is 256
    mdlDisplayPath_getInfoString(path, infoStr);
    mdlDisplayPath_release(path);
    displayMsg("DisplayPath InfoStr=%S", infoStr);
    }