by Michael S. Kaplan, published on 2008/08/03 12:31 -04:00, original URI: http://blogs.msdn.com/b/michkap/archive/2008/08/03/8819230.aspx
The question is actually one that has come from a few different people, most recently from a developer named Jeff:
How can I keep the Language Bar up for my C# application?
Or if that isn't possible, how can I make it come back up after it has been minimized to the tray?
Like I said, it turns out to be a common question. :-)
There are two solutions here, one for each of the subquestions in Jeff's inquiry....
There is a thread on the WinForms forum entitled How do I keep Language Bar showing to the user in remote desktop application? that explains how to disallow minimizing -- if you deny modify permissions to HKCU\software\microsoft\TSF then you can't minimize the Language Bar at all.
Though to be honest this is a bit heavy handed, in my opinion. If they want to minimize it at a given moment then I hate taking away the option to do so.
But I would like to make it easy to have it pop back up!
So let's move past that solution and think about the second one, shall we? :-)
To make the Language Bar do your bidding, what you really want an object that implements the ITfLangBarMgr interface. Because you can use the ITfLangBarMgr::ShowFloating method to control all of the various aspects of the language bar from how it shows up to how transparent it is to how many icons it shows to whether the text labels are there and so on.
The C# part will make this a bit harder, of course....
Now there is a TF_CreateLangBarMgr function exported by msctf.dll that make it easy to get the ITfLangBarMgr interface pointer. And obviously it is easy to enough to call Marshal.ReleaseComObject on that object after you are done and keep the documentation in that function call which is so worried about refcounts from having a big "I told you so" moment on your code.
But the middle part, the one that calls ITfLangBarMgr::ShowFloating with the TF_SFT_DHOWNORMAL flag, that requires you to actually have the interface defined if you really want to call the method from C#. Not impossible, but definitely some extra work made much harder by the fact that this one is in COM.
Personally, I'm pining for an awesome sample to do all this coming out of the TSF Aware Blog. This is, after all, a nice, easily contained sample that would be tremendously useful to a lot of people.
This is my subtle hint to Eric Brown to encourage him to combine his extensive TSF knowledge with the wonderful science of COM Interop to show off one of the more feasible uses of C# and the Text Services Framework that he has suggested in the past. :-)
I suppose I could cobble together a sample too, eventually. Everything to do the work is documented and understood, and even COM Interop is not so hard if you don't try to make it so. But I'm hoping it gets done before I get to it....
Anyway, that is the answer to this question that seems to come quite a bit for some reason. Perhaps also a message to the Text Services Framework team to make the "un-minimizing" support easier, too? :-)
This blog brought to you by ଵ (U+0b35, aka ORIYA LETTER VA)