1

I've implemented class that inherits ITfLanguageProfileNotifySink interface. It's working, I can get event when language changes, but it's only when my app is focused.

What should I do to detect language changes in my app when it's not focused?

Eric Brown
  • 13,774
  • 7
  • 30
  • 71
  • I've found this very usefull blog http://blogs.msdn.com/b/tsfaware/archive/2007/05/21/transitory-extensions.aspx It seems I need to implement ITfThreadMgrEventSink interface, and try to check if context is transitory. Sadly, I can't compile the code in this blog. – user3133467 Jan 15 '14 at 12:42
  • Which version of Windows are you running on? In 7 and below, the language state is *per process*, so there's no need to detect language changes when the app isn't focused. – Eric Brown Jan 15 '14 at 16:44
  • Also, the comment you posted has to do with detecting transitory contexts, so I'm not sure what that has to do with language changes. – Eric Brown Jan 15 '14 at 16:45
  • I'm running on windows 7. I thought, transitory contexts may be used to advise *EventSink interface to app that has focus(active). Is it possible to implement the processing of messages(events) about changing the language for any application that in focus by tfs? I want to catch this event and process it in my app. – user3133467 Jan 17 '14 at 05:41
  • Since you're running on Windows 7, the keyboard layout is per-process. Transitory contexts are there to allow text services to perform temporary manipulations of the document state until the character is completed. They're mostly useful along with compositions. Again, not terribly related to language/keyboard layout changes. – Eric Brown Jan 17 '14 at 17:34
  • I think there may be an XY problem here. What problem are you trying to solve that requires a global notification of keyboard layout changes? – Eric Brown Jan 17 '14 at 17:34
  • So why do you need a *global* notification of keyboard layout change? Surely you can do this locally. If nothing else, send the keyboard layout as part of the translation request. – Eric Brown Jan 17 '14 at 20:17
  • I probably don't understand how it all works. How can I do this locally? – user3133467 Jan 17 '14 at 21:21
  • Via `ITfLanguageProfileNotifySink` (for language changes) or `ITfActiveLanguageProfileNotifySink` (for IME changes). Again, Windows 7 keyboard layouts are specific to the process, so changing the keyboard layout in one process (with focus) doesn't change the keyboard layout in processes without focus. When you switch back, the keyboard layout changes as well. – Eric Brown Jan 18 '14 at 04:18
  • Contact me via email and we'll resolve it, and I'll post an answer once the confusion is resolved. – Eric Brown Jan 18 '14 at 04:21
  • I've sent you email via your blog. – user3133467 Jan 18 '14 at 15:20

1 Answers1

1

ITfLanguageProfileNotifySink is the interface you want, but you need to implement it in your text service DLL, rather than in a core application.

You will need to implement a text service DLL in any case if you want to interact with the text in a document, as TSF interfaces don't have proxies & stubs, and can't run cross-process.

Eric Brown
  • 13,774
  • 7
  • 30
  • 71