共用方式為


IModelObject::GetParentModel 方法 (dbgmodel.h)

GetParentModel 方法會傳回指定物件父模型鏈結中的第 i 個父模型。 父模型會依新增或列舉的線性順序搜尋屬性或概念。 索引 i 為零的父模型會在索引 i + 1 的父模型之前搜尋(階層式)。

語法

HRESULT GetParentModel(
  ULONG64      i,
  IModelObject **model,
  IModelObject **contextObject
);

參數

i

線性以零起始的索引,表示要擷取鏈結中的父模型。

model

代表第一個父模型的 IModelObject 將會在這裡傳回。

contextObject

如果父模型具有相關聯的內容調整器,將會在這裡傳回調整的內容。 如需此值的詳細資訊,請參閱 AddParentModel 的檔。

傳回值

此方法會傳回表示成功或失敗的 HRESULT。

言論

程式代碼範例

ComPtr<IModelObject> spObject; /* get an object */

ULONG64 numModels;
if (SUCCEEDED(spObject->GetNumberOfParentModels(&numModels)))
{
    // Enumerate the set of parents in linear resolution order:
    for (ULONG64 i = 0; i < numModels; ++i)
    {
        ComPtr<IModelObject> spParent;
        ComPtr<IModelObject> spContextAdjustor;
        if (SUCCEEDED(spObject->GetParentModel(i, &spParent, &spContextAdjustor)))
        {
            // spParent contains the i-th parent model
            // spContext optionally contains a context adjustor.  Properties above 
            //     this in the tree will use this context instead of spObject.
            //     Conceptually, this is a *this* pointer thunk/adjustor.  The 
            //     adjustor can be a property which must be fetched instead of a static value.
        }
    }
}

要求

要求 價值
標頭 dbgmodel.h

另請參閱

IModelObject 介面