As I mentioned earlier, TSF provides very basic services in applications that are not TSF-aware. In particular, TSF provides only transitory documents and contexts that represent short-lived text compositions. In Windows Vista, TSF adds full text store support for some frequently-used text controls - plain edit controls, richedit controls (that don't enable TSF), and Trident edit controls in Internet Explorer.
However, text services do not automatically get this text store support; services must inquire if the support is available. That is, TSF-unaware controls have two documents (and contexts) - the real (transitory) document, and the (TSF-provided) virtual document. In general, text services may wish to use both documents, depending on the editing purpose - one-shot insertions and corrections should use the virtual document, while the real (transitory) document should be used for keyboard input compositions and other kinds of inputs with transitory states.
So, how does a text service get the virtual document?
HRESULT CMyTextService::OnSetFocus(ITfDocumentMgr* pdimFocus, ITfDocumentMgr pdimPrevFocus)
bool isTransitory = false;
isTransitory = (tsStatus & TS_SS_TRANSITORY) == TS_SS_TRANSITORY;
if (SUCCEEDED(spCompartment->GetValue(&var)) && var.vt == VT_UNKNOWN && var.punkVal)
var.punkVal->QueryInterface( IID_ITfDocumentMgr, (void**)&spParentDIM);
Once you have the virtual document, your focus change code can use the virtual document as if it were the main document.
Some things to keep in mind: