共用方式為


CUtlProps::OnPropertyChanged

會在設定屬性之後的繫結屬性。

virtual HRESULT OnPropertyChanged( 
   ULONG /* iCurSet */, 
   DBPROP* pDBProp  
);

參數

  • iCurSet
    索引屬性集合陣列中;零,如果只有一個屬性集合。

  • pDBProp
    屬性 ID 和新的值在 DBPROP 結構。

傳回值

標準 HRESULT。 預設傳回值為 S_OK。

備註

如果您要處理繫結的屬性,例如值取決於其他屬性值的書籤或更新,您應該覆寫這個函式。

範例

在這個函式,使用者從 DBPROP* 參數取得屬性 ID。 現在,對屬性比較 ID 與鏈結是可能的。 當找到屬性時, SetProperties 會使用與另一個屬性搭配現在要設定的屬性。 在這種情況下,,則會取得 DBPROP_IRowsetLocate、 DBPROP_LITERALBOOKMARKS或 DBPROP_ORDEREDBOOKMARKS 屬性,則可以設定 DBPROP_BOOKMARKS 屬性。

HRESULT OnPropertyChanged(ULONG /*iCurSet*/, DBPROP* pDBProp)
{
   ATLASSERT(pDBProp != NULL);

   DWORD dwPropertyID = pDBProp->dwPropertyID;

   if (dwPropertyID == DBPROP_IRowsetLocate || 
      dwPropertyID == DBPROP_LITERALBOOKMARKS ||
      dwPropertyID == DBPROP_ORDEREDBOOKMARKS)
   {
      CComVariant var = pDBProp->vValue;

      if (var.boolVal == VARIANT_TRUE)
      {
         // Set the bookmarks property as these are chained
         CComVariant bookVar(true);
         CDBPropSet set(DBPROPSET_ROWSET);
         set.AddProperty(DBPROP_BOOKMARKS, bookVar);

         return SetProperties(1, &set);
      }
   }

   return S_OK;
}

需求

Header: atldb.h

請參閱

參考

CUtlProps 類別