本文整理汇总了C++中COMPtr::get_accName方法的典型用法代码示例。如果您正苦于以下问题:C++ COMPtr::get_accName方法的具体用法?C++ COMPtr::get_accName怎么用?C++ COMPtr::get_accName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类COMPtr
的用法示例。
在下文中一共展示了COMPtr::get_accName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: name
static void CALLBACK logEventProc(HWINEVENTHOOK, DWORD event, HWND hwnd, LONG idObject, LONG idChild, DWORD, DWORD)
{
// Get the accessible object for this event.
COMPtr<IAccessible> parentObject;
VARIANT vChild;
VariantInit(&vChild);
HRESULT hr = AccessibleObjectFromEvent(hwnd, idObject, idChild, &parentObject, &vChild);
ASSERT(SUCCEEDED(hr));
// Get the name of the focused element, and log it to stdout.
BSTR nameBSTR;
hr = parentObject->get_accName(vChild, &nameBSTR);
ASSERT(SUCCEEDED(hr));
wstring name(nameBSTR, ::SysStringLen(nameBSTR));
SysFreeString(nameBSTR);
switch (event) {
case EVENT_OBJECT_FOCUS:
printf("Received focus event for object '%S'.\n", name.c_str());
break;
case EVENT_OBJECT_SELECTION:
printf("Received selection event for object '%S'.\n", name.c_str());
break;
case EVENT_OBJECT_VALUECHANGE: {
BSTR valueBSTR;
hr = parentObject->get_accValue(vChild, &valueBSTR);
ASSERT(SUCCEEDED(hr));
wstring value(valueBSTR, ::SysStringLen(valueBSTR));
SysFreeString(valueBSTR);
printf("Received value change event for object '%S', value '%S'.\n", name.c_str(), value.c_str());
break;
}
case EVENT_SYSTEM_SCROLLINGSTART:
printf("Received scrolling start event for object '%S'.\n", name.c_str());
break;
default:
printf("Received unknown event for object '%S'.\n", name.c_str());
break;
}
VariantClear(&vChild);
}