Wenn ich versuche, einen Event-Handler zu meinem Automatisierungsobjekt hinzuzufügen, erhalte ich immer die Fehlermeldung E_POINTER
Zum Beispiel schlägt der folgende Code fehl.
Code: Select all
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;
}
Ich habe das gleiche Problem mit AddPropertyChangedEventHandler
Mobile version