STDAPI CExtentMonitorTextService::OnSetFocus(ITfDocumentMgr *pDocMgrFocus, ITfDocumentMgr *pDocMgrPrevFocus)
{

    //
    // Whenever focus is changed, we initialize the TextEditSink.
    //
    ITfDocumentMgr *pDocMgrTarget = NULL;
    if (GetNonTransitoryDim(pDocMgrFocus, &pDocMgrTarget) != S_OK)
    {
        if (pDocMgrFocus)
        {
            pDocMgrTarget = pDocMgrFocus;
            pDocMgrTarget->AddRef();
        }
    }

    _InitTextEditSink(pDocMgrTarget);

    if (pDocMgrTarget)
    {
        ITfContext *pContext;
        if (SUCCEEDED(pDocMgrTarget->GetBase(&pContext)))
        {
            DumpExtent(pContext, DE_EVENTID_ONSETFOCUS);
            pContext->Release();
        }
        pDocMgrTarget->Release();
    }

    return S_OK;
}