IUIAutomation::AddFocusChangedEventHandler 메서드(uiautomationclient.h)

포커스 변경 이벤트를 처리하는 메서드를 등록합니다.

참고 이벤트 처리기를 구현하기 전에 스레딩 문제 이해에 설명된 스레딩 문제에 대해 잘 알고 있어야 합니다.
 

구문

HRESULT AddFocusChangedEventHandler(
  [in] IUIAutomationCacheRequest             *cacheRequest,
  [in] IUIAutomationFocusChangedEventHandler *handler
);

매개 변수

[in] cacheRequest

형식: IUIAutomationCacheRequest*

캐시 요청에 대한 포인터이거나 캐싱이 필요하지 않은 경우 NULL 입니다.

[in] handler

형식: IUIAutomationFocusChangedEventHandler*

이벤트를 처리하는 개체에 대한 포인터입니다.

반환 값

형식: HRESULT

메서드가 성공하면 S_OK를 반환하고, 그러지 않으면 HRESULT 오류 코드를 반환합니다.

설명

포커스 변경 이벤트는 시스템 전체입니다. 더 좁은 scope 설정할 수 없습니다.

UI 자동화 클라이언트는 여러 스레드를 사용하여 이벤트 처리기를 추가하거나 제거해서는 안 됩니다. 동일한 클라이언트 프로세스에서 다른 이벤트 처리기가 추가되거나 제거되는 동안 한 이벤트 처리기가 추가되거나 제거되는 경우 예기치 않은 동작이 발생할 수 있습니다.

예제

다음 예제 함수는 IUIAutomationFocusChangedEventHandler 를 구현하고 처리기를 추가하여 이벤트를 구독하는 개체를 만듭니다.

HRESULT AddFocusHandler(IUIAutomation* pAutomation)
{ 
    // CFocusHandler is a class that implements IUIAutomationFocusChangedEventHandler. 
    CFocusHandler* pFocusHandler = new CFocusHandler();
    if (!pFocusHandler)
    {
        return E_OUTOFMEMORY;
    }
    IUIAutomationFocusChangedEventHandler* pHandler;
    pFocusHandler->QueryInterface(IID_IUIAutomationFocusChangedEventHandler, (void**)&pHandler);
    HRESULT hr = pAutomation->AddFocusChangedEventHandler(NULL, pHandler);
    pFocusHandler->Release();
    return hr;
}

요구 사항

요구 사항
지원되는 최소 클라이언트 Windows 7, WINDOWS Vista SP2 및 Windows Vista용 플랫폼 업데이트, WINDOWS XP SP3 및 Windows Vista용 플랫폼 업데이트 [데스크톱 앱만 해당]
지원되는 최소 서버 Windows Server 2008 R2, Windows Server 2008 SP2 및 Windows Server 2008용 플랫폼 업데이트, Windows Server 2003 SP2 및 Windows Server 2008용 플랫폼 업데이트 [데스크톱 앱만 해당]
대상 플랫폼 Windows
헤더 uiautomationclient.h(UIAutomation.h 포함)

추가 정보

UI 자동화 속성 및 컨트롤 패턴 캐싱

개념

IUIAutomation

IUIAutomationFocusChangedEventHandler

참조

RemoveAllEventHandlers

RemoveFocusChangedEventHandler

UI 자동화 이벤트 구독

스레딩 문제 이해