Когда я пытаюсь добавить какой-либо обработчик событий к моему объекту автоматизации, я всегда получаю сообщение об ошибке E_POINTER
Например, следующий код не работает.
Код: Выделить всё
HRESULT STDMETHODCALLTYPE CUIAutomation::QueryInterface(REFIID riid, void** ppInterface)
{
if (riid == __uuidof(IUnknown))
*ppInterface = static_cast(this);
else if (riid == __uuidof(IUIAutomationFocusChangedEventHandler))
*ppInterface = static_cast(this);
else if (riid == __uuidof(IUIAutomationEventHandler))
*ppInterface = static_cast(this);
else
{
*ppInterface = NULL;
return E_NOINTERFACE;
}
this->AddRef();
return S_OK;
}
HRESULT STDMETHODCALLTYPE CUIAutomation::HandleFocusChangedEvent(IUIAutomationElement *sender)
{
HRESULT hr = S_OK;
controlTypeId_ = 0;
isPassword_ = FALSE;
processId_ = 0;
logged_ = false;
// these work
sender->get_CachedControlType(&controlTypeId_);
sender->get_CachedIsPassword(&isPassword_);
sender->get_CachedProcessId(&processId_);
sender->get_CachedName(&name_);
sender->get_CachedAutomationId(&automationId_);
if (watchedElement_ == NULL)
{
PROPERTYID watchedProperties_[] = { UIA_ControlTypePropertyId };
if (automationId_ == "urlbar-input")
{
// this returns E_POINTER
hr = pAutomation_->AddAutomationEventHandler(UIA_Text_TextChangedEventId, sender, TreeScope_Element, NULL, this);
if (SUCCEEDED(hr))
{
watchedElement_ = sender;
}
}
}
return S_OK;
}
У меня та же проблема с AddPropertyChangedEventHandler
Подробнее здесь: https://stackoverflow.com/questions/798 ... -e-pointer
Мобильная версия