IUISimplePropertySet
COM公式ドキュメント
IUISimplePropertySet は、プロパティ キーで識別される値を取得するメソッドを定義する読み取り専用インターフェイスです。
メソッド 1
vtbl = vtable インデックス(0始まり)。HSP等からCOMメソッドをインデックス指定で呼ぶ際に使用します。0〜2 は IUnknown。
vtbl 3 HRESULT GetValue(PROPERTYKEY* key, PROPVARIANT* value)
プロパティ キーで識別される値を取得します。
| key | PROPERTYKEY* | in | 対象となる プロパティ キー。 |
| value | PROPVARIANT* | out | このメソッドが返るときに、 key に対応する値へのポインターが格納されます。 |
戻り値
型: HRESULT
このメソッドが成功した場合は S_OK を返します。それ以外の場合は HRESULT エラー コードを返します。
解説(Remarks)
例
次の例では、アイテム ギャラリーとコマンド ギャラリーの両方に対応する IUISimplePropertySet のカスタム実装を示します。
この例の CItemProperties クラスは IUISimplePropertySet から派生しており、必須のメソッドである IUISimplePropertySet::GetValue に加えて、初期化とインデックス管理のための一連のヘルパー関数を実装しています。
//
// PURPOSE: Implementation of IUISimplePropertySet.
//
// COMMENTS:
// Three gallery-specific helper functions added.
//
class CItemProperties
: public CComObjectRootEx<CComMultiThreadModel>
, public IUISimplePropertySet
{
public:
// COM map for QueryInterface of IUISimplePropertySet.
BEGIN_COM_MAP(CItemProperties)
COM_INTERFACE_ENTRY(IUISimplePropertySet)
END_COM_MAP()
// Required method that enables property key values to be
// retrieved on gallery collection items.
STDMETHOD(GetValue)(REFPROPERTYKEY key, PROPVARIANT *ppropvar)
{
HRESULT hr;
// A Command gallery.
// _isCommandGallery set on item initialization.
if (_isCommandGallery)
{
if(key == UI_PKEY_CommandId && _isCommandGallery)
{
// Return a pointer to the CommandId of the item.
return InitPropVariantFromUInt32(_cmdID, ppropvar);
}
}
// An item gallery.
else
{
if (key == UI_PKEY_Label)
{
// Return a pointer to the item label string.
return UIInitPropertyFromString(
UI_PKEY_Label, g_labels[_index], ppropvar);
}
else if(key == UI_PKEY_ItemImage)
{
if (NULL == _spimgItem)
{
hr = CreateUIImageFromBitmapResource(
MAKEINTRESOURCE(IDB_GALLERYITEM), &_spimgItem);
if (FAILED(hr))
{
return hr;
}
}
// Return a pointer to the item image.
return UIInitPropertyFromImage(
UI_PKEY_ItemImage, _spimgItem, ppropvar);
}
}
return E_NOTIMPL;
}
// Initialize an item in an item gallery collection at the specified index.
void Initialize(int index)
{
_index = index;
_cmdID = 0;
_isCommandGallery = false;
}
// Initialize a Command in a Command gallery.
void InitializeAsCommand(__in UINT cmdID)
{
_index = 0;
_cmdID = cmdID;
_isCommandGallery = true;
}
// Gets the index of the selected item in an item gallery.
int GetIndex()
{
return _index;
}
private:
int _index;
int _cmdID;
bool _isCommandGallery;
CComPtr<IUIImage> _spimgItem;
};
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
HSP用 COM定義
#usecom / #comfunc によるHSPのCOM呼び出し定義。数字は vtbl インデックス(0始まり)。クラスIDが無い場合 #usecom の末尾は "{}"、ある場合は "{CLSID}"。
出力引数:
#define global IID_IUISimplePropertySet "{C205BB48-5B1C-4219-A106-15BD0A5F24E2}" #usecom global IUISimplePropertySet IID_IUISimplePropertySet "{}" #comfunc global IUISimplePropertySet_GetValue 3 var,var ; ※数字は vtbl インデックス(0始まり)。0/1/2 は IUnknown(QueryInterface/AddRef/Release)。 ; ※このインターフェースは直接 CoCreateInstance するクラスIDが無いため "{}"(他メソッド/アクティベーションで取得)。 ; ※出力/バッファ引数は var(変数直渡し)。varptr 方式にも切替可。#define global IID_IUISimplePropertySet "{C205BB48-5B1C-4219-A106-15BD0A5F24E2}" #usecom global IUISimplePropertySet IID_IUISimplePropertySet "{}" #comfunc global IUISimplePropertySet_GetValue 3 sptr,sptr ; ※数字は vtbl インデックス(0始まり)。0/1/2 は IUnknown(QueryInterface/AddRef/Release)。 ; ※このインターフェースは直接 CoCreateInstance するクラスIDが無いため "{}"(他メソッド/アクティベーションで取得)。 ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。