question

WindmillCity avatar image
0 Votes"
WindmillCity asked WindmillCity edited

[TSF-Application] How to use Text Service Framework on Multithreaded Apartment thread

Trying to Activate the UI-Thread which is in Multithreaded Apartment, but it seems the call to ITfThreadMgr->Activate has no effect.

windows-apic++
· 9
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

For debugging purposes I suggest you change from an assignment to ATL's CComQIPtr (which doesn't return an HRESULT upon failure) to a conventional call to QueryInterface to provide some more diagnostic information. Alternatively, you could step through the ATL internals to determine the HRESULT of the failed QueryInterface call.

0 Votes 0 ·

57171-image.png


It says No_Interface, but in STA Thread, it returns right item

0 Votes 0 ·
image.png (2.4 KiB)

Maybe you need to obtain the interface pointer in an STA thread and marshal it to you MTA thread.

0 Votes 0 ·
Show more comments

1 Answer

WindmillCity avatar image
0 Votes"
WindmillCity answered WindmillCity edited

Since the instance of ITfThreadMgr created by CoCreateInstance only for Apartment Thread, you should use TF_CreateThreadMgr to create a threadMgr that can be used in both Apartment Thread and MultiThreaded Thread.
https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-tf_createthreadmgr

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.