using System; using System.Runtime.InteropServices; using System.Runtime.InteropServices.ComTypes; using Vanara.Collections; using Vanara.InteropServices; using static Vanara.PInvoke.Ole32; using LPARAM = System.IntPtr; using TfClientId = System.UInt32; using TfEditCookie = System.UInt32; using TfGuidAtom = System.UInt32; using WPARAM = System.IntPtr; namespace Vanara.PInvoke { public static partial class MSCTF { /// /// The IEnumITfCompositionView interface is implemented by the TSF manager to provide an enumeration of composition view objects. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nn-msctf-ienumitfcompositionview [PInvokeData("msctf.h", MSDNShortId = "NN:msctf.IEnumITfCompositionView")] [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("5EFD22BA-7838-46CB-88E2-CADB14124F8F")] public interface IEnumITfCompositionView : ICOMEnum { /// Creates a copy of the enumerator object. /// Pointer to an IEnumITfCompositionView interface pointer that receives the new enumerator. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumitfcompositionview-clone HRESULT Clone( // IEnumITfCompositionView **ppEnum ); IEnumITfCompositionView Clone(); /// Obtains, from the current position, the specified number of elements in the enumeration sequence. /// Specifies the number of elements to obtain. /// /// Pointer to an array of ITfCompositionView interface pointers that receives the requested objects. This array must be at /// least ulCount elements in size. /// /// /// Pointer to a ULONG value that receives the number of elements obtained. This value can be less than the number of items /// requested. This parameter can be NULL. /// /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// S_FALSE /// The method reached the end of the enumeration before the specified number of elements could be obtained. /// /// /// E_INVALIDARG /// rgCompositionView is invalid. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumitfcompositionview-next HRESULT Next( ULONG ulCount, // ITfCompositionView **rgCompositionView, ULONG *pcFetched ); [PreserveSig] HRESULT Next(uint ulCount, [Out, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Interface)] ITfCompositionView[] rgCompositionView, [NullAllowed] out uint pcFetched); /// Resets the enumerator object by moving the current position to the beginning of the enumeration sequence. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumitfcompositionview-reset HRESULT Reset(); void Reset(); /// Moves the current position forward in the enumeration sequence by the specified number of elements. /// Contains the number of elements to skip. /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// S_FALSE /// The method reached the end of the enumeration before the specified number of elements could be skipped. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumitfcompositionview-skip HRESULT Skip( ULONG ulCount ); [PreserveSig] HRESULT Skip(uint ulCount); } /// The IEnumTfContexts interface is implemented by the TSF manager to provide an enumeration of context objects. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nn-msctf-ienumtfcontexts [PInvokeData("msctf.h", MSDNShortId = "NN:msctf.IEnumTfContexts")] [ComImport, Guid("8F1A7EA6-1654-4502-A86E-B2902344D507"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IEnumTfContexts : ICOMEnum { /// Creates a copy of the enumerator object. /// Pointer to an IEnumTfContexts interface pointer that receives the new enumerator. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumtfcontexts-clone HRESULT Clone( IEnumTfContexts // **ppEnum ); IEnumTfContexts Clone(); /// Obtains, from the current position, the specified number of elements in the enumeration sequence. /// Specifies the number of elements to obtain. /// /// Pointer to an array of ITfContext interface pointers that receives the requested objects. This array must be at least /// ulCount elements in size. /// /// /// Pointer to a ULONG value that receives the number of elements actually obtained. This value can be less than the number of /// items requested. This parameter can be NULL. /// /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// S_FALSE /// The method reached the end of the enumeration before the specified number of elements could be obtained. /// /// /// E_INVALIDARG /// rgContext is invalid. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumtfcontexts-next HRESULT Next( ULONG ulCount, // ITfContext **rgContext, ULONG *pcFetched ); [PreserveSig] HRESULT Next(uint ulCount, [Out, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Interface)] ITfContext[] rgContext, [NullAllowed] out uint pcFetched); /// Resets the enumerator object by moving the current position to the beginning of the enumeration sequence. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumtfcontexts-reset HRESULT Reset(); void Reset(); /// Moves the current position forward in the enumeration sequence by the specified number of elements. /// Contains the number of elements to skip. /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// S_FALSE /// The method reached the end of the enumeration before the specified number of elements could be skipped. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumtfcontexts-skip HRESULT Skip( ULONG ulCount ); [PreserveSig] HRESULT Skip(uint ulCount); } /// Not implemented. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nn-msctf-ienumtfcontextviews [PInvokeData("msctf.h", MSDNShortId = "NN:msctf.IEnumTfContextViews")] [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("F0C0F8DD-CF38-44E1-BB0F-68CF0D551C78")] public interface IEnumTfContextViews : ICOMEnum { /// This method has no parameters. /// This method does not return a value. // https://docs.microsoft.com/en-us/windows/win32/tsf/ienumtfcontextviews-clone void (); IEnumTfContextViews Clone(); /// Obtains, from the current position, the specified number of elements in the enumeration sequence. /// Specifies the number of elements to obtain. /// /// Pointer to an array of ITfContextView interface pointers that receives the requested objects. This array must be at least /// ulCount elements in size. /// /// /// Pointer to a ULONG value that receives the number of elements actually obtained. This value can be less than the number of /// items requested. This parameter can be NULL. /// /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// S_FALSE /// The method reached the end of the enumeration before the specified number of elements could be obtained. /// /// /// E_INVALIDARG /// rgViews is invalid. /// /// /// [PreserveSig] HRESULT Next(uint ulCount, [Out, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Interface)] ITfContextView[] rgViews, [NullAllowed] out uint pcFetched); /// This method has no parameters. /// This method does not return a value. // https://docs.microsoft.com/en-us/windows/win32/tsf/ienumtfcontextviews-reset void (); void Reset(); /// This method has no parameters. /// This method does not return a value. // https://docs.microsoft.com/en-us/windows/win32/tsf/ienumtfcontextviews-skip void (); [PreserveSig] HRESULT Skip(uint ulCount); } /// /// The IEnumTfDisplayAttributeInfo interface is implemented by the TSF manager to provide an enumeration of display /// attribute information objects. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nn-msctf-ienumtfdisplayattributeinfo [PInvokeData("msctf.h", MSDNShortId = "NN:msctf.IEnumTfDisplayAttributeInfo")] [ComImport, Guid("7CEF04D7-CB75-4E80-A7AB-5F5BC7D332DE"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IEnumTfDisplayAttributeInfo : ICOMEnum { /// Creates a copy of the enumerator object. /// Pointer to an IEnumTfDisplayAttributeInfo interface pointer that receives the new enumerator. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumtfdisplayattributeinfo-clone HRESULT Clone( // IEnumTfDisplayAttributeInfo **ppEnum ); IEnumTfDisplayAttributeInfo Clone(); /// Obtains, from the current position, the specified number of elements in the enumeration sequence. /// Specifies the number of elements to obtain. /// /// Pointer to an array of ITfDisplayAttributeInfo interface pointers that receives the requested objects. This array must be at /// least ulCount elements in size. /// /// /// Pointer to a ULONG value that receives the number of elements actually obtained. The number of elements can be less than the /// number of items requested. This parameter can be NULL. /// /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// S_FALSE /// The method reached the end of the enumeration before the specified number of elements were obtained. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumtfdisplayattributeinfo-next HRESULT Next( ULONG // ulCount, ITfDisplayAttributeInfo **rgInfo, ULONG *pcFetched ); [PreserveSig] HRESULT Next(uint ulCount, [Out, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Interface)] ITfDisplayAttributeInfo[] rgInfo, [NullAllowed] out uint pcFetched); /// Resets the enumerator object by moving the current position to the beginning of the enumeration sequence. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumtfdisplayattributeinfo-reset HRESULT Reset(); void Reset(); /// Moves the current position forward in the enumeration sequence by the specified number of elements. /// Contains the number of elements to skip. /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// S_FALSE /// The method reached the end of the enumeration before the specified number of elements could be skipped. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumtfdisplayattributeinfo-skip HRESULT Skip( ULONG // ulCount ); [PreserveSig] HRESULT Skip(uint ulCount); } /// /// The IEnumTfDocumentMgrs interface is implemented by the TSF manager to provide an enumeration of document manager objects. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nn-msctf-ienumtfdocumentmgrs [PInvokeData("msctf.h", MSDNShortId = "NN:msctf.IEnumTfDocumentMgrs")] [ComImport, Guid("AA80E808-2021-11D2-93E0-0060B067B86E"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IEnumTfDocumentMgrs : ICOMEnum { /// Creates a copy of the enumerator object. /// Pointer to an IEnumTfDocumentMgrs interface pointer that receives the new enumerator. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumtfdocumentmgrs-clone HRESULT Clone( // IEnumTfDocumentMgrs **ppEnum ); IEnumTfDocumentMgrs Clone(); /// Obtains, from the current position, the specified number of elements in the enumeration sequence. /// Specifies the number of elements to obtain. /// /// Pointer to an array of ITfDocumentMgr interface pointers that receives the requested objects. This array must be at least /// ulCount elements in size. /// /// /// Pointer to a ULONG value that receives the number of elements actually obtained. This value can be less than the number of /// items requested. This parameter can be NULL. /// /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// S_FALSE /// The method reached the end of the enumeration before the specified number of elements were obtained. /// /// /// E_INVALIDARG /// rgDocumentMgr is invalid. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumtfdocumentmgrs-next HRESULT Next( ULONG ulCount, // ITfDocumentMgr **rgDocumentMgr, ULONG *pcFetched ); [PreserveSig] HRESULT Next(uint ulCount, [Out, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Interface)] ITfDocumentMgr[] rgDocumentMgr, [NullAllowed] out uint pcFetched); /// Resets the enumerator object by moving the current position to the beginning of the enumeration sequence. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumtfdocumentmgrs-reset HRESULT Reset(); void Reset(); /// Moves the current position forward in the enumeration sequence by the specified number of elements. /// Contains the number of elements to skip. /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// S_FALSE /// The method reached the end of the enumeration before the specified number of elements could be skipped. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumtfdocumentmgrs-skip HRESULT Skip( ULONG ulCount ); [PreserveSig] HRESULT Skip(uint ulCount); } /// /// The IEnumTfFunctionProviders interface is implemented by the TSF manager to provide an enumeration of function provider objects. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nn-msctf-ienumtffunctionproviders [PInvokeData("msctf.h", MSDNShortId = "NN:msctf.IEnumTfFunctionProviders")] [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("E4B24DB0-0990-11D3-8DF0-00105A2799B5")] public interface IEnumTfFunctionProviders : ICOMEnum { /// Creates a copy of the enumerator object. /// Pointer to an IEnumTfFunctionProviders interface pointer that receives the new enumerator. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumtffunctionproviders-clone HRESULT Clone( // IEnumTfFunctionProviders **ppEnum ); IEnumTfFunctionProviders Clone(); /// Obtains, from the current position, the specified number of elements in the enumeration sequence. /// Specifies the number of elements to obtain. /// /// Pointer to an array of ITfFunctionProvider interface pointers that receives the requested objects. This array must be at /// least ulCount elements in size. /// /// /// Pointer to a ULONG value that receives the number of elements obtained. This value can be less than the number of items /// requested. This parameter can be NULL. /// /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// S_FALSE /// The method reached the end of the enumeration before the specified number of elements could be obtained. /// /// /// E_INVALIDARG /// ppCmdobj is invalid. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumtffunctionproviders-next HRESULT Next( ULONG ulCount, // ITfFunctionProvider **ppCmdobj, ULONG *pcFetch ); [PreserveSig] HRESULT Next(uint ulCount, [Out, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Interface)] ITfFunctionProvider[] ppCmdobj, [NullAllowed] out uint pcFetch); /// Resets the enumerator object by moving the current position to the beginning of the enumeration sequence. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumtffunctionproviders-reset HRESULT Reset(); void Reset(); /// Moves the current position forward in the enumeration sequence by the specified number of elements. /// Contains the number of elements to skip. /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// S_FALSE /// The method reached the end of the enumeration before the specified number of elements could be skipped. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumtffunctionproviders-skip HRESULT Skip( ULONG ulCount ); [PreserveSig] HRESULT Skip(uint ulCount); } /// /// The IEnumTfInputProcessorProfiles interface is implemented by TSF manager and used by applications or textservices. This /// interface can be retrieved by ITfInputProcessorProfileMgr::EnumProfiles and enumerates the registered profiles. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nn-msctf-ienumtfinputprocessorprofiles [PInvokeData("msctf.h", MSDNShortId = "NN:msctf.IEnumTfInputProcessorProfiles")] [ComImport, Guid("71C6E74D-0F28-11D8-A82A-00065B84435C"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IEnumTfInputProcessorProfiles : ICOMEnum { /// The IEnumTfInputProcessorProfiles::Clone method creates a copy of the enumerator object. /// [out] A pointer to an IEnumTfInputProcessorProfiles interface. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumtfinputprocessorprofiles-clone HRESULT Clone( // IEnumTfInputProcessorProfiles **ppEnum ); IEnumTfInputProcessorProfiles Clone(); /// /// The IEnumTfInputProcessorProfiles::Next method obtains, from the current position, the specified number of elements /// in the enumeration sequence. /// /// [in] Specifies the number of elements to obtain. /// /// [out] Pointer to an array of TF_INPUTPROCESSORPROFILE structures. This array must be at least ulCount elements in size. /// /// /// [out] Pointer to a ULONG value that receives the number of elements actually obtained. This value can be less than the /// number of items requested. This parameter can be NULL. /// /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// E_FAIL /// An unspecified error occurred. /// /// /// E_INVALIDARG /// One or more parameters are invalid. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumtfinputprocessorprofiles-next HRESULT Next( ULONG // ulCount, TF_INPUTPROCESSORPROFILE *pProfile, ULONG *pcFetch ); [PreserveSig] HRESULT Next(uint ulCount, [Out, MarshalAs(UnmanagedType.LPArray)] TF_INPUTPROCESSORPROFILE[] pProfile, out uint pcFetch); /// /// The IEnumTfInputProcessorProfiles::Reset method resets the enumerator object by moving the current position to the beginning /// of the enumeration sequence. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumtfinputprocessorprofiles-reset HRESULT Reset(); void Reset(); /// /// The IEnumTfInputProcessorProfiles::Skip method moves the current position forward in the enumeration sequence by the /// specified number of elements. /// /// [in] Contains the number of elements to skip. /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// E_FALSE /// The method reached the end of the enumeration before the specified number of elements could be skipped. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumtfinputprocessorprofiles-skip HRESULT Skip( ULONG // ulCount ); [PreserveSig] HRESULT Skip(uint ulCount); } /// /// The IEnumTfLangBarItems interface is implemented by the TSF manager to provide an enumeration of langauge bar item objects. /// // https://docs.microsoft.com/en-us/windows/win32/api/ctfutb/nn-ctfutb-ienumtflangbaritems [PInvokeData("ctfutb.h", MSDNShortId = "NN:ctfutb.IEnumTfLangBarItems")] [ComImport, Guid("583F34D0-DE25-11D2-AFDD-00105A2799B5"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IEnumTfLangBarItems : ICOMEnum { /// Creates a copy of the enumerator object. /// Pointer to an IEnumTfLangBarItems interface pointer that receives the new enumerator. // https://docs.microsoft.com/en-us/windows/win32/api/ctfutb/nf-ctfutb-ienumtflangbaritems-clone HRESULT Clone( // IEnumTfLangBarItems **ppEnum ); IEnumTfLangBarItems Clone(); /// Obtains the specified number of elements in the enumeration sequence from the current position. /// Specifies the number of elements to obtain. /// /// Pointer to an array of ITfLangBarItem interface pointers that receives the requested objects. This array must be at least /// ulCount elements in size. /// /// /// [in, out] Pointer to a ULONG value that receives the number of elements obtained. This value can be less than the number of /// items requested. This parameter can be NULL. /// /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// S_FALSE /// The method reached the end of the enumeration before the specified number of elements could be obtained. /// /// /// E_INVALIDARG /// ppItem is invalid. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/ctfutb/nf-ctfutb-ienumtflangbaritems-next HRESULT Next( ULONG ulCount, // ITfLangBarItem **ppItem, ULONG *pcFetched ); [PreserveSig] HRESULT Next(uint ulCount, [Out, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Interface)] ITfLangBarItem[] ppItem, [NullAllowed] out uint pcFetched); /// Resets the enumerator object by moving the current position to the beginning of the enumeration sequence. // https://docs.microsoft.com/en-us/windows/win32/api/ctfutb/nf-ctfutb-ienumtflangbaritems-reset HRESULT Reset(); void Reset(); /// Moves the current position forward in the enumeration sequence by the specified number of elements. /// Contains the number of elements to skip. /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// S_FALSE /// The method reached the end of the enumeration before the specified number of elements could be skipped. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/ctfutb/nf-ctfutb-ienumtflangbaritems-skip HRESULT Skip( ULONG ulCount ); [PreserveSig] HRESULT Skip(uint ulCount); } /// /// The IEnumTfLanguageProfiles interface is implemented by the TSF manager to provide an enumeration of language profiles. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nn-msctf-ienumtflanguageprofiles [PInvokeData("msctf.h", MSDNShortId = "NN:msctf.IEnumTfLanguageProfiles")] [ComImport, Guid("3D61BF11-AC5F-42C8-A4CB-931BCC28C744"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IEnumTfLanguageProfiles : ICOMEnum { /// Creates a copy of the enumerator object. /// Pointer to an IEnumTfLanguageProfiles interface pointer that receives the new enumerator. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumtflanguageprofiles-clone HRESULT Clone( // IEnumTfLanguageProfiles **ppEnum ); IEnumTfLanguageProfiles Clone(); /// Obtains, from the current position, the specified number of elements in the enumeration sequence. /// Specifies the number of elements to obtain. /// /// Pointer to an array of TF_LANGUAGEPROFILE structures that receives the requested data. This array must be at least ulCount /// elements in size. /// /// /// Pointer to a ULONG value that receives the number of elements obtained. This value can be less than the number of items /// requested. This parameter can be NULL. /// /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// S_FALSE /// The method reached the end of the enumeration before the specified number of elements could be obtained. /// /// /// E_INVALIDARG /// pProfile is invalid. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumtflanguageprofiles-next HRESULT Next( ULONG ulCount, // TF_LANGUAGEPROFILE *pProfile, ULONG *pcFetch ); [PreserveSig] HRESULT Next(uint ulCount, [Out, MarshalAs(UnmanagedType.LPArray)] TF_LANGUAGEPROFILE[] pProfile, [NullAllowed] out uint pcFetch); /// Resets the enumerator object by moving the current position to the beginning of the enumeration sequence. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumtflanguageprofiles-reset HRESULT Reset(); void Reset(); /// Moves the current position forward in the enumeration sequence by the specified number of elements. /// Contains the number of elements to skip. /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// S_FALSE /// The method reached the end of the enumeration before the specified number of elements could be skipped. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumtflanguageprofiles-skip HRESULT Skip( ULONG ulCount ); [PreserveSig] HRESULT Skip(uint ulCount); } /// The IEnumTfProperties interface is implemented by the TSF manager to provide an enumeration of property objects. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nn-msctf-ienumtfproperties [PInvokeData("msctf.h", MSDNShortId = "NN:msctf.IEnumTfProperties")] [ComImport, Guid("19188CB0-ACA9-11D2-AFC5-00105A2799B5"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IEnumTfProperties : ICOMEnum { /// Creates a copy of the enumerator object. /// Pointer to an IEnumTfProperties interface pointer that receives the new enumerator. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumtfproperties-clone HRESULT Clone( IEnumTfProperties // **ppEnum ); IEnumTfProperties Clone(); /// Obtains, from the current position, the specified number of elements in the enumeration sequence. /// Specifies the number of elements to obtain. /// /// Pointer to an array of ITfProperty interface pointers that receives the requested objects. This array must be at least /// ulCount elements in size. /// /// /// Pointer to a ULONG that receives the number of elements obtained. This value can be less than the number of items requested. /// This parameter can be NULL. /// /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// S_FALSE /// The method reached the end of the enumeration before the specified number of elements could be obtained. /// /// /// E_INVALIDARG /// ppProp is invalid. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumtfproperties-next HRESULT Next( ULONG ulCount, // ITfProperty **ppProp, ULONG *pcFetched ); [PreserveSig] HRESULT Next(uint ulCount, [Out, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Interface)] ITfProperty[] ppProp, [NullAllowed] out uint pcFetched); /// Resets the enumerator object by moving the current position to the beginning of the enumeration sequence. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumtfproperties-reset HRESULT Reset(); void Reset(); /// Moves the current position forward in the enumeration sequence by the specified number of elements. /// Contains the number of elements to skip. /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// S_FALSE /// The method reached the end of the enumeration before the specified number of elements could be skipped. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumtfproperties-skip HRESULT Skip( ULONG ulCount ); [PreserveSig] HRESULT Skip(uint ulCount); } /// /// The IEnumTfPropertyValue interface is implemented by the TSF manager to provide an enumeration of property values. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nn-msctf-ienumtfpropertyvalue [PInvokeData("msctf.h", MSDNShortId = "NN:msctf.IEnumTfPropertyValue")] [ComImport, Guid("8ED8981B-7C10-4D7D-9FB3-AB72E9C75F72"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IEnumTfPropertyValue : ICOMEnum { /// Creates a copy of the enumerator object. /// Pointer to an IEnumTfPropertyValue interface pointer that receives the new enumerator. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumtfpropertyvalue-clone HRESULT Clone( // IEnumTfPropertyValue **ppEnum ); IEnumTfPropertyValue Clone(); /// Obtains, from the current position, the specified number of elements in the enumeration sequence. /// Specifies the number of elements to obtain. /// /// Pointer to an array of TF_PROPERTYVAL structures that receives the requested objects. This array must be at least ulCount /// elements in size. /// /// /// Pointer to a ULONG value that receives the number of elements actually obtained. This value can be less than the number of /// items requested. This parameter can be NULL. /// /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// S_FALSE /// The method reached the end of the enumeration before the specified number of elements could be obtained. /// /// /// E_INVALIDARG /// rgValues is invalid. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumtfpropertyvalue-next HRESULT Next( ULONG ulCount, // TF_PROPERTYVAL *rgValues, ULONG *pcFetched ); [PreserveSig] HRESULT Next(uint ulCount, [Out, MarshalAs(UnmanagedType.LPArray)] TF_PROPERTYVAL[] rgValues, [NullAllowed] out uint pcFetched); /// Resets the enumerator object by moving the current position to the beginning of the enumeration sequence. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumtfpropertyvalue-reset HRESULT Reset(); void Reset(); /// Moves the current position forward in the enumeration sequence by the specified number of elements. /// Contains the number of elements to skip. /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// S_FALSE /// The method reached the end of the enumeration before the specified number of elements could be skipped. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumtfpropertyvalue-skip HRESULT Skip( ULONG ulCount ); [PreserveSig] HRESULT Skip(uint ulCount); } /// The IEnumTfRanges interface is implemented by the TSF manager to provide an enumeration of range objects. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nn-msctf-ienumtfranges [PInvokeData("msctf.h", MSDNShortId = "NN:msctf.IEnumTfRanges")] [ComImport, Guid("F99D3F40-8E32-11D2-BF46-00105A2799B5"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IEnumTfRanges : ICOMEnum { /// Creates a copy of the enumerator object. /// Pointer to an IEnumTfRanges interface pointer that receives the new enumerator. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumtfranges-clone HRESULT Clone( IEnumTfRanges **ppEnum ); IEnumTfRanges Clone(); /// Obtains, from the current position, the specified number of elements in the enumeration sequence. /// Specifies the number of elements to obtain. /// /// Pointer to an array of ITfRange interface pointers that receives the requested objects. This array must be at least ulCount /// elements in size. /// /// /// Pointer to a ULONG value that receives the number of elements actually obtained. This value can be less than the number of /// items requested. This parameter can be NULL. /// /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// S_FALSE /// The method reached the end of the enumeration before the specified number of elements could be obtained. /// /// /// E_INVALIDARG /// ppRange is invalid. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumtfranges-next HRESULT Next( ULONG ulCount, ITfRange // **ppRange, ULONG *pcFetched ); [PreserveSig] HRESULT Next(uint ulCount, [Out, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Interface)] ITfRange[] ppRange, [NullAllowed] out uint pcFetched); /// Resets the enumerator object by moving the current position to the beginning of the enumeration sequence. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumtfranges-reset HRESULT Reset(); void Reset(); /// Moves the current position forward in the enumeration sequence by the specified number of elements. /// Contains the number of elements to skip. /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// S_FALSE /// The method reached the end of the enumeration before the specified number of elements could be skipped. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumtfranges-skip HRESULT Skip( ULONG ulCount ); [PreserveSig] HRESULT Skip(uint ulCount); } /// /// The IEnumTfUIElements interface is implemented by TSF manager and used by applications or textservices. This interface /// can be retrieved by ITfUIElementMgr::EnumUIElements and enumerates the registered UI elements. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nn-msctf-ienumtfuielements [PInvokeData("msctf.h", MSDNShortId = "NN:msctf.IEnumTfUIElements")] [ComImport, Guid("887AA91E-ACBA-4931-84DA-3C5208CF543F"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IEnumTfUIElements : ICOMEnum { /// The IEnumTfUIElements::Clone method creates a copy of the enumerator object. /// [out] A pointer to a IEnumTfUIElements interface. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumtfuielements-clone HRESULT Clone( IEnumTfUIElements // **ppEnum ); IEnumTfUIElements Clone(); /// /// The IEnumTfUIElements::Next method obtains, from the current position, the specified number of elements in the /// enumeration sequence. /// /// [out] Specifies the number of elements to obtain. /// /// [out] Pointer to an array of ITfUIElement interface pointer. This array must be at least ulCount elements in size. /// /// /// [out] Pointer to a ULONG value that receives the number of elements actually obtained. This value can be less than the /// number of items requested. This parameter can be NULL. /// /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// S_FALSE /// The method reached the end of the enumeration before the specified number of elements could be obtained. /// /// /// E_INVALIDARG /// One or more parameters are invalid. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumtfuielements-next HRESULT Next( ULONG ulCount, // ITfUIElement **ppElement, ULONG *pcFetched ); [PreserveSig] HRESULT Next(uint ulCount, [Out, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Interface)] ITfUIElement[] ppElement, [NullAllowed] out uint pcFetched); /// /// The IEnumTfUIElements::Reset method resets the enumerator object by moving the current position to the beginning of /// the enumeration sequence. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumtfuielements-reset HRESULT Reset(); void Reset(); /// /// The IEnumTfUIElements::Skip method obtains, from the current position, the specified number of elements in the /// enumeration sequence. /// /// [in] Specifies the number of elements to skip. /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// S_FALSE /// The method reached the end of the enumeration before the specified number of elements could be skipped. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-ienumtfuielements-skip HRESULT Skip( ULONG ulCount ); [PreserveSig] HRESULT Skip(uint ulCount); } /// /// The ITextStoreACPServices interface is implemented by the TSF manager to provide various services to an ACP-based /// application. To obtain an instance of this interface, an application calls QueryInterface on the punk parameter passed to /// ITextStoreACP::AdviseSink with IID_ITextStoreACPServices. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nn-msctf-itextstoreacpservices [PInvokeData("msctf.h", MSDNShortId = "NN:msctf.ITextStoreACPServices")] [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("AA80E901-2021-11D2-93E0-0060B067B86E")] public interface ITextStoreACPServices { /// Obtains a property from a range of text and writes the property data into a stream object. /// Pointer to an ITfProperty interface that identifies the property to serialize. /// Pointer to an ITfRange interface that identifies the range that the property is obtained from. /// Pointer to a TF_PERSISTENT_PROPERTY_HEADER_ACP structure that receives the header data for the property. /// Pointer to an IStream object that the TSF manager will write the property data to. /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// S_FALSE /// The property cannot be serialized. /// /// /// E_FAIL /// An unspecified error occurred. /// /// /// /// /// /// The property header data placed in pHdr is generic to all properties and must be preserved with the data written into /// pStream. This same data pair must be passed to ITextStoreACPServices::Unserialize to restore the property data. /// /// An application can save all of the properties for the entire document by performing the following steps. /// /// /// Enumerate all properties using ITfContext::EnumProperties. /// /// /// Within each property, enumerate the ranges using ITfReadOnlyProperty::EnumRanges. /// /// /// Pass the current property and range to ITextStoreACPServices::Serialize. /// /// /// Write the data placed in pHdr to the file. /// /// /// Write the data added to pStream to the file. /// /// /// When calling this method, the application must be able to grant a synchronous read-only lock. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itextstoreacpservices-serialize HRESULT Serialize( // ITfProperty *pProp, ITfRange *pRange, TF_PERSISTENT_PROPERTY_HEADER_ACP *pHdr, IStream *pStream ); void Serialize([In] ITfProperty pProp, [In] ITfRange pRange, out TF_PERSISTENT_PROPERTY_HEADER_ACP pHdr, [In] IStream pStream); /// Takes previously serialized property data and applies it to a property object. /// Pointer to an ITfProperty object that receives the property data. /// Pointer to a TF_PERSISTENT_PROPERTY_HEADER_ACP structure that contains the header data for the property. /// /// Pointer to an IStream object that contains the property data. This parameter can be NULL if pLoader is not /// NULL. This parameter is ignored if pLoader is not NULL. /// /// /// Pointer to an ITfPersistentPropertyLoaderACP object that the TSF manager will use to obtain the property data. This /// parameter can be NULL if pStream is not NULL. /// /// /// /// If pStream is specified rather than pLoader, the property data will be read from pStream during the call to /// Unserialize . If pLoader is specified rather than pStream, the property data will be read from pLoader /// asynchronously. Using pStream can cause long delays if the property data is large. /// /// While calling this method, the application must be able to grant a synchronous read-only lock. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itextstoreacpservices-unserialize HRESULT Unserialize( // ITfProperty *pProp, const TF_PERSISTENT_PROPERTY_HEADER_ACP *pHdr, IStream *pStream, ITfPersistentPropertyLoaderACP *pLoader ); void Unserialize([In] ITfProperty pProp, in TF_PERSISTENT_PROPERTY_HEADER_ACP pHdr, [In, Optional] IStream pStream, [In, Optional] ITfPersistentPropertyLoaderACP pLoader); /// Forces all values of an asynchronously loaded property to be loaded. /// Pointer to an ITfProperty object that specifies the property to load. /// When calling this method, the application must be able to grant a synchronous read-only lock. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itextstoreacpservices-forceloadproperty HRESULT // ForceLoadProperty( ITfProperty *pProp ); void ForceLoadProperty([In] ITfProperty pProp); /// Creates a range object from two ACP values. /// Contains the starting position of the range. /// Contains the ending position of the range. /// Pointer to an ITfRangeACP interface pointer that receives the range object. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itextstoreacpservices-createrange HRESULT CreateRange( LONG // acpStart, LONG acpEnd, ITfRangeACP **ppRange ); ITfRangeACP CreateRange(int acpStart, int acpEnd); } /// /// /// The ITfActiveLanguageProfileNotifySink interface is implemented by an application to receive a notification when the /// active language or text service changes. /// /// /// To install the advise sink, obtain an ITfSource object from an ITfThreadMgr object by calling /// ITfThreadMgr::QueryInterface with IID_ITfActiveLanguageProfileNotifySink. Then call ITfSource::AdviseSink with IID_ITfActiveLanguageProfileNotifySink. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nn-msctf-itfactivelanguageprofilenotifysink [PInvokeData("msctf.h", MSDNShortId = "NN:msctf.ITfActiveLanguageProfileNotifySink")] [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("B246CB75-A93E-4652-BF8C-B3FE0CFD7E57")] public interface ITfActiveLanguageProfileNotifySink { /// Called when the active language or text service changes. /// CLSID of the TSF text service activated or deactivated. This will be NULL for a language change. /// /// Profile GUID for the TSF text service. This is specified by the TSF text service when it is installed. This will be /// NULL for a language change. /// /// TRUE if the TSF text service is activated or FALSE if the TSF text service is deactivated. /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfactivelanguageprofilenotifysink-onactivated HRESULT // OnActivated( REFCLSID clsid, REFGUID guidProfile, BOOL fActivated ); [PreserveSig] HRESULT OnActivated([In, Optional] GuidPtr clsid, [In, Optional] GuidPtr guidProfile, [MarshalAs(UnmanagedType.Bool)] bool fActivated); } /// /// /// The ITfCandidateList interface is implemented by a text service and is used by the TSF manager or a client (application /// or other text service) to obtain and manipulate candidate string objects. /// /// /// The TSF manager implements this interface to provide access to this interface to other clients. This enables the TSF manager to /// function as a mediator between the client and the text service. /// /// To obtain an instance of this interface the TSF manager or client can call ITfFnReconversion::GetReconversion. /// /// /// When a text service must interpret text before it is inserted into a context, there might be more than one possible /// interpretation of the text. Speech input is an example of this. If the spoken word is "there", other possible interpretations /// might be "their" or "they're". The text service will insert the most appropriate text, but there is still some chance of error /// involved. Text reconversion is the process of allowing the user to select alternate text for the inserted text. The alternate /// text objects are known as candidates. /// // https://docs.microsoft.com/en-us/windows/win32/api/ctffunc/nn-ctffunc-itfcandidatelist [PInvokeData("ctffunc.h", MSDNShortId = "NN:ctffunc.ITfCandidateList")] [ComImport, Guid("A3AD50FB-9BDB-49E3-A843-6C76520FBF5D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface ITfCandidateList { /// Obtains an enumerator that contains all the candidate string objects in the candidate list. /// /// Pointer to an IEnumTfCandidates interface pointer that receives the enumerator object. The caller must release this /// interface when it is no longer required. /// /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// E_INVALIDARG /// ppEnum is invalid. /// /// /// E_OUTOFMEMORY /// A memory allocation failure occurred. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/ctffunc/nf-ctffunc-itfcandidatelist-enumcandidates HRESULT EnumCandidates( // IEnumTfCandidates **ppEnum ); [PreserveSig] HRESULT EnumCandidates(out IEnumTfCandidates ppEnum); /// Obtains a specific candidate string object. /// Specifies the zero-based index of the candidate string to obtain. /// /// Pointer to an ITfCandidateString interface pointer that receives the candidate string object. The caller must release this /// interface when it is no longer required. /// /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// E_FAIL /// nIndex is invalid. /// /// /// E_INVALIDARG /// ppCand is invalid. /// /// /// E_OUTOFMEMORY /// A memory allocation failure occurred. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/ctffunc/nf-ctffunc-itfcandidatelist-getcandidate HRESULT GetCandidate( // ULONG nIndex, ITfCandidateString **ppCand ); [PreserveSig] HRESULT GetCandidate(uint nIndex, out ITfCandidateString ppCand); /// Obtains the number of candidate string objects in the candidate list. /// /// Pointer to a ULONG value that receives the number of candidate string objects in the candidate list. /// /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// E_INVALIDARG /// pnCnt is invalid. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/ctffunc/nf-ctffunc-itfcandidatelist-getcandidatenum HRESULT // GetCandidateNum( ULONG *pnCnt ); [PreserveSig] HRESULT GetCandidateNum(out uint pnCnt); /// Specifies the result of a reconversion operation for s specific candidate string. /// /// Specifies the zero-based index of the candidate string to set the result for. This parameter is ignored if imcr contains CAND_CANCELED. /// /// Contains one of the TfCandidateResult values that specifies the result of the reconversion operation. /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// E_FAIL /// An unspecified error occurred. /// /// /// /// /// A typical reconversion operation would include the following operations. /// /// /// A list of candidates is obtained and displayed to the user in a dialog box. /// /// /// /// When the user selects a candidate, but before the dialog box is dismissed, ITfCandidateList::SetResult is called with /// the index of the newly selected candidate and CAND_SELECTED. /// /// /// /// /// If a different candidate is selected, ITfCandidateList::SetResult is called agian with the index of the newly /// selected candidate and CAND_SELECTED. /// /// /// /// /// If the user chooses to accept the new candidate, ITfCandidateList::SetResult is called with the index of the /// currently selected candidate and CAND_FINALIZED. /// /// /// /// If the user cancels the dialog, ITfCandidateList::SetResult is called with an index of zero and CAND_CANCELED. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/ctffunc/nf-ctffunc-itfcandidatelist-setresult HRESULT SetResult( ULONG // nIndex, TfCandidateResult imcr ); [PreserveSig] HRESULT SetResult(uint nIndex, [In] TfCandidateResult imcr); } /// The ITfCandidateListUIElement interface is implemented by a text service that has the candidate list UI. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nn-msctf-itfcandidatelistuielement [PInvokeData("msctf.h", MSDNShortId = "NN:msctf.ITfCandidateListUIElement")] [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("EA1EA138-19DF-11D7-A6D2-00065B84435C")] public interface ITfCandidateListUIElement : ITfUIElement { /// The ITfUIElement::GetDescription method returns the description of the UI element. /// [in] A pointer to BSTR that contains the description of the UI element. /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// E_FAIL /// An unspecified error occurred. /// /// /// E_INVALIDARG /// One or more parameters are invalid. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfuielement-getdescription HRESULT GetDescription( BSTR // *pbstrDescription ); [PreserveSig] new HRESULT GetDescription([Out, MarshalAs(UnmanagedType.BStr)] out string pbstrDescription); /// The ITfUIElement::GetGUID method returns the unique id of this UI element. /// [out] A pointer to receive the GUID of the UI element. /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// E_FAIL /// An unspecified error occurred. /// /// /// E_INVALIDARG /// One or more parameters are invalid. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfuielement-getguid HRESULT GetGUID( GUID *pguid ); [PreserveSig] new HRESULT GetGUID(out Guid pguid); /// The ITfUIElement::Show method shows the text service's UI of this UI element. /// /// [in] TRUE to show the original UI of the element. FALSE to hide the original UI of the element. /// /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// E_FAIL /// An unspecified error occurred. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfuielement-show HRESULT Show( BOOL bShow ); [PreserveSig] new HRESULT Show([In, MarshalAs(UnmanagedType.Bool)] bool bShow); /// /// The ITfUIElement::IsShown method returns true if the UI is currently shown by a text service; otherwise false. /// /// [out] A pointer to bool of the current show status of the original UI of this element. /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// E_FAIL /// An unspecified error occurred. /// /// /// E_INVALIDARG /// One or more parameters are invalid. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfuielement-isshown HRESULT IsShown( BOOL *pbShow ); [PreserveSig] new HRESULT IsShown([Out, MarshalAs(UnmanagedType.Bool)] out bool pbShow); /// /// The ITfCandidateListUIElement::GetUpdatedFlags method returns the flag that tells which part of this element was updated. /// /// /// [out] a pointer to receive the flags that is a combination of the following bits: /// /// /// Value /// Meaning /// /// /// TF_CLUIE_DOCUMENTMGR /// The target document manager was changed. /// /// /// TF_CLUIE_COUNT /// The count of the candidate string was changed. /// /// /// TF_CLUIE_SELECTION /// The selection of the candidate was changed. /// /// /// TF_CLUIE_STRING /// Some strings in the list were changed. /// /// /// TF_CLUIE_PAGEINDEX /// The current page index or some page index was changed. /// /// /// TF_CLUIE_CURRENTPAGE /// The page was changed. /// /// /// /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// E_FAIL /// An unspecified error occurred. /// /// /// E_INVALIDARG /// One or more parameters are invalid. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcandidatelistuielement-getupdatedflags HRESULT // GetUpdatedFlags( DWORD *pdwFlags ); [PreserveSig] HRESULT GetUpdatedFlags(out TF_CLUIE pdwFlags); /// The ITfCandidateListUIElement::GetDocumentMgr method returns the target document manager of this UI. /// [out] A pointer to receive ITfDocumentMgr interface pointer. /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// E_FAIL /// An unspecified error occurred. /// /// /// E_INVALIDARG /// One or more parameters are invalid. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcandidatelistuielement-getdocumentmgr HRESULT // GetDocumentMgr( ITfDocumentMgr **ppdim ); [PreserveSig] HRESULT GetDocumentMgr(out ITfDocumentMgr ppdim); /// The ITfCandidateListUIElement::GetCount method returns the count of the candidate strings. /// [out] A pointer to receive a count of the candidate strings. /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// E_FAIL /// An unspecified error occurred. /// /// /// E_INVALIDARG /// One or more parameters are invalid. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcandidatelistuielement-getcount HRESULT GetCount( UINT // *puCount ); [PreserveSig] HRESULT GetCount(out uint puCount); /// The ITfCandidateListUIElement::GetSelection method returns the current selection of the candidate list. /// [out] A pointer to receive an index of the current selected candidate string. /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// E_FAIL /// An unspecified error occurred. /// /// /// E_INVALIDARG /// One or more parameters are invalid. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcandidatelistuielement-getselection HRESULT // GetSelection( UINT *puIndex ); [PreserveSig] HRESULT GetSelection(out uint puIndex); /// The ITfCandidateListUIElement::GetString method returns the string of the index. /// [in] An index of the string to obtain. /// [out] A pointer to BSTR for the candidate string of the index. /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// E_FAIL /// An unspecified error occurred. /// /// /// E_INVALIDARG /// One or more parameters are invalid. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcandidatelistuielement-getstring HRESULT GetString( UINT // uIndex, BSTR *pstr ); [PreserveSig] HRESULT GetString(uint uIndex, [Out, MarshalAs(UnmanagedType.BStr)] out string pstr); /// The ITfCandidateListUIElement::GetPageIndex method returns the page index of the list. /// /// [out] A pointer that receives an array of the indexes that each page starts from. This can be NULL. The caller calls /// this method with NULL for this parameter first to get the number of pages in puPageCnt and allocates the buffer to /// receive indexes for all pages. /// /// [in] A buffer size of pIndex. /// [out] A pointer to receive the page count. /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// E_FAIL /// An unspecified error occurred. /// /// /// E_INVALIDARG /// One or more parameters are invalid. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcandidatelistuielement-getpageindex HRESULT // GetPageIndex( UINT *pIndex, UINT uSize, UINT *puPageCnt ); [PreserveSig] HRESULT GetPageIndex([Out, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] uint[] pIndex, uint uSize, out uint puPageCnt); /// The ITfCandidateListUIElement::SetPageIndex method sets the page index. /// [in] A pointer to an array of the indexes that each page starts from. /// [in] A page count. The size of the pIndex buffer. /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// E_FAIL /// An unspecified error occurred. /// /// /// E_INVALIDARG /// One or more parameters are invalid. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcandidatelistuielement-setpageindex HRESULT // SetPageIndex( UINT *pIndex, UINT uPageCnt ); [PreserveSig] HRESULT SetPageIndex([In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] uint[] pIndex, uint uPageCnt); /// The ITfCandidateListUIElement::GetCurrentPage method returns the current page. /// [in] A pointer to receive the current page index. /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// E_FAIL /// An unspecified error occurred. /// /// /// E_INVALIDARG /// One or more parameters are invalid. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcandidatelistuielement-getcurrentpage HRESULT // GetCurrentPage( UINT *puPage ); [PreserveSig] HRESULT GetCurrentPage(out uint puPage); } /// /// This interface is implemented by a text service that has a candidate list UI and its UI can be controlled by the application. /// The application QI this interface from ITfUIElement and controls the candidate list behavior. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nn-msctf-itfcandidatelistuielementbehavior [PInvokeData("msctf.h", MSDNShortId = "NN:msctf.ITfCandidateListUIElementBehavior")] [ComImport, Guid("85FAD185-58CE-497A-9460-355366B64B9A"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface ITfCandidateListUIElementBehavior : ITfCandidateListUIElement { /// The ITfUIElement::GetDescription method returns the description of the UI element. /// [in] A pointer to BSTR that contains the description of the UI element. /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// E_FAIL /// An unspecified error occurred. /// /// /// E_INVALIDARG /// One or more parameters are invalid. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfuielement-getdescription HRESULT GetDescription( BSTR // *pbstrDescription ); [PreserveSig] new HRESULT GetDescription([Out, MarshalAs(UnmanagedType.BStr)] out string pbstrDescription); /// The ITfUIElement::GetGUID method returns the unique id of this UI element. /// [out] A pointer to receive the GUID of the UI element. /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// E_FAIL /// An unspecified error occurred. /// /// /// E_INVALIDARG /// One or more parameters are invalid. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfuielement-getguid HRESULT GetGUID( GUID *pguid ); [PreserveSig] new HRESULT GetGUID(out Guid pguid); /// The ITfUIElement::Show method shows the text service's UI of this UI element. /// /// [in] TRUE to show the original UI of the element. FALSE to hide the original UI of the element. /// /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// E_FAIL /// An unspecified error occurred. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfuielement-show HRESULT Show( BOOL bShow ); [PreserveSig] new HRESULT Show([In, MarshalAs(UnmanagedType.Bool)] bool bShow); /// /// The ITfUIElement::IsShown method returns true if the UI is currently shown by a text service; otherwise false. /// /// [out] A pointer to bool of the current show status of the original UI of this element. /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// E_FAIL /// An unspecified error occurred. /// /// /// E_INVALIDARG /// One or more parameters are invalid. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfuielement-isshown HRESULT IsShown( BOOL *pbShow ); [PreserveSig] new HRESULT IsShown([Out, MarshalAs(UnmanagedType.Bool)] out bool pbShow); /// /// The ITfCandidateListUIElement::GetUpdatedFlags method returns the flag that tells which part of this element was updated. /// /// /// [out] a pointer to receive the flags that is a combination of the following bits: /// /// /// Value /// Meaning /// /// /// TF_CLUIE_DOCUMENTMGR /// The target document manager was changed. /// /// /// TF_CLUIE_COUNT /// The count of the candidate string was changed. /// /// /// TF_CLUIE_SELECTION /// The selection of the candidate was changed. /// /// /// TF_CLUIE_STRING /// Some strings in the list were changed. /// /// /// TF_CLUIE_PAGEINDEX /// The current page index or some page index was changed. /// /// /// TF_CLUIE_CURRENTPAGE /// The page was changed. /// /// /// /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// E_FAIL /// An unspecified error occurred. /// /// /// E_INVALIDARG /// One or more parameters are invalid. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcandidatelistuielement-getupdatedflags HRESULT // GetUpdatedFlags( DWORD *pdwFlags ); [PreserveSig] new HRESULT GetUpdatedFlags(out TF_CLUIE pdwFlags); /// The ITfCandidateListUIElement::GetDocumentMgr method returns the target document manager of this UI. /// [out] A pointer to receive ITfDocumentMgr interface pointer. /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// E_FAIL /// An unspecified error occurred. /// /// /// E_INVALIDARG /// One or more parameters are invalid. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcandidatelistuielement-getdocumentmgr HRESULT // GetDocumentMgr( ITfDocumentMgr **ppdim ); [PreserveSig] new HRESULT GetDocumentMgr(out ITfDocumentMgr ppdim); /// The ITfCandidateListUIElement::GetCount method returns the count of the candidate strings. /// [out] A pointer to receive a count of the candidate strings. /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// E_FAIL /// An unspecified error occurred. /// /// /// E_INVALIDARG /// One or more parameters are invalid. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcandidatelistuielement-getcount HRESULT GetCount( UINT // *puCount ); [PreserveSig] new HRESULT GetCount(out uint puCount); /// The ITfCandidateListUIElement::GetSelection method returns the current selection of the candidate list. /// [out] A pointer to receive an index of the current selected candidate string. /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// E_FAIL /// An unspecified error occurred. /// /// /// E_INVALIDARG /// One or more parameters are invalid. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcandidatelistuielement-getselection HRESULT // GetSelection( UINT *puIndex ); [PreserveSig] new HRESULT GetSelection(out uint puIndex); /// The ITfCandidateListUIElement::GetString method returns the string of the index. /// [in] An index of the string to obtain. /// [out] A pointer to BSTR for the candidate string of the index. /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// E_FAIL /// An unspecified error occurred. /// /// /// E_INVALIDARG /// One or more parameters are invalid. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcandidatelistuielement-getstring HRESULT GetString( UINT // uIndex, BSTR *pstr ); [PreserveSig] new HRESULT GetString(uint uIndex, [Out, MarshalAs(UnmanagedType.BStr)] out string pstr); /// The ITfCandidateListUIElement::GetPageIndex method returns the page index of the list. /// /// [out] A pointer that receives an array of the indexes that each page starts from. This can be NULL. The caller calls /// this method with NULL for this parameter first to get the number of pages in puPageCnt and allocates the buffer to /// receive indexes for all pages. /// /// [in] A buffer size of pIndex. /// [out] A pointer to receive the page count. /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// E_FAIL /// An unspecified error occurred. /// /// /// E_INVALIDARG /// One or more parameters are invalid. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcandidatelistuielement-getpageindex HRESULT // GetPageIndex( UINT *pIndex, UINT uSize, UINT *puPageCnt ); [PreserveSig] new HRESULT GetPageIndex([Out, Optional, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] uint[] pIndex, uint uSize, out uint puPageCnt); /// The ITfCandidateListUIElement::SetPageIndex method sets the page index. /// [in] A pointer to an array of the indexes that each page starts from. /// [in] A page count. The size of the pIndex buffer. /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// E_FAIL /// An unspecified error occurred. /// /// /// E_INVALIDARG /// One or more parameters are invalid. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcandidatelistuielement-setpageindex HRESULT // SetPageIndex( UINT *pIndex, UINT uPageCnt ); [PreserveSig] new HRESULT SetPageIndex([In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] uint[] pIndex, uint uPageCnt); /// The ITfCandidateListUIElement::GetCurrentPage method returns the current page. /// [in] A pointer to receive the current page index. /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// E_FAIL /// An unspecified error occurred. /// /// /// E_INVALIDARG /// One or more parameters are invalid. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcandidatelistuielement-getcurrentpage HRESULT // GetCurrentPage( UINT *puPage ); [PreserveSig] new HRESULT GetCurrentPage(out uint puPage); /// The ITfCandidateListUIElementBehavior::SetSelection method set the selection of the candidate list. /// [in] An index for the candidate string to be selected. /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// E_FAIL /// An unspecified error occurred. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcandidatelistuielementbehavior-setselection HRESULT // SetSelection( UINT nIndex ); [PreserveSig] HRESULT SetSelection(uint nIndex); /// /// The ITfCandidateListUIElementBehavior::Finalize method finalizes the current selection and close the candidate list. /// /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// E_FAIL /// An unspecified error occurred. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcandidatelistuielementbehavior-finalize HRESULT Finalize(); [PreserveSig] HRESULT Finalize(); /// /// The ITfCandidateListUIElementBehavior::Abort method closes the candidate list. There is no guarantee that the current /// selection will be finalized. /// /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// E_FAIL /// An unspecified error occurred. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcandidatelistuielementbehavior-abort HRESULT Abort(); [PreserveSig] HRESULT Abort(); } /// /// The ITfCategoryMgr interface manages categories of objects for text services. The TSF manager implements this interface. /// /// TSF categories help organize objects identified by a globally unique identifier ( GUID ). For example, a class identifier ( /// CLSID ) identifies a text service, and a GUID identifies the TSF compartment, TSF properties, and TSF display attributes. To /// group and organize multiple GUIDs, TSF uses category identifiers ( CATIDs). /// /// /// The category manager uses an internal table, accessed with keys called GUID atoms to cache the GUIDs. Access to GUIDs is /// efficient using these atoms. When a GUID is obtained using its atom, the GUID description and value can be obtained from the /// Windows registry. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nn-msctf-itfcategorymgr [PInvokeData("msctf.h", MSDNShortId = "NN:msctf.ITfCategoryMgr")] [ComImport, Guid("C3ACEFB5-F69D-4905-938F-FCADCF4BE830"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), CoClass(typeof(TF_CategoryMgr))] public interface ITfCategoryMgr { /// Adds a specified GUID to the specified category in the Windows registry. /// Contains the CLSID of the text service that owns the item. /// /// Contains a GUID value that identifies the category to register the item under. This can be a user-defined category or one of /// the predefined category values. /// /// Contains a GUID value that identifies the item to register. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcategorymgr-registercategory HRESULT RegisterCategory( // REFCLSID rclsid, REFGUID rcatid, REFGUID rguid ); void RegisterCategory(in Guid rclsid, in Guid rcatid, in Guid rguid); /// Removes a specified GUID from the specified category in the Windows registry. /// Contains the CLSID of the text service that owns the item. /// Contains a GUID that identifies the category that the item is registered under. /// Contains a GUID that identifies the item to remove. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcategorymgr-unregistercategory HRESULT // UnregisterCategory( REFCLSID rclsid, REFGUID rcatid, REFGUID rguid ); void UnregisterCategory(in Guid rclsid, in Guid rcatid, in Guid rguid); /// Obtains an IEnumGUID interface that enumerates all categories to which the specified GUID belongs. /// Contains a GUID value that identifies the item to enumerate the categories for. /// Pointer to an IEnumGUID interface pointer that receives the enumerator. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcategorymgr-enumcategoriesinitem HRESULT // EnumCategoriesInItem( REFGUID rguid, IEnumGUID **ppEnum ); IEnumGUID EnumCategoriesInItem(in Guid rguid); /// Obtains an IEnumGUID interface that enumerates all GUIDs included in the specified category. /// Contains a GUID value that identifies the category to enumerate the items for. /// Pointer to an IEnumGUID interface pointer that receives the enumerator. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcategorymgr-enumitemsincategory HRESULT // EnumItemsInCategory( REFGUID rcatid, IEnumGUID **ppEnum ); IEnumGUID EnumItemsInCategory(in Guid rcatid); /// Finds the category closest to the specified GUID from a list of categories. /// Specifies the address of the GUID for which to find the closest category. /// Pointer to the GUID that receives the CATID for the closest category. /// Pointer to a pointer that specifies an array of CATIDs to search for the closest category. /// Specifies the number of elements in the array of the ppcatidList parameter. /// /// The closest category to a GUID is chosen in one of two modes. In the first mode, the method receives a non-empty /// category list. It chooses the first matching CATID from that list or GUID_NULL if the list does not contain a /// category that contains the GUID . In the second mode, it receives an empty category list. It chooses the first /// category that contains the GUID or GUID_NULL if no category contains the GUID . /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcategorymgr-findclosestcategory HRESULT // FindClosestCategory( REFGUID rguid, GUID *pcatid, const GUID **ppcatidList, ULONG ulCount ); void FindClosestCategory(in Guid rguid, out Guid pcatid, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] Guid[] ppcatidList, uint ulCount); /// Enters a description for a GUID previously registered in the Windows registry. /// Contains the CLSID of the text service that owns the GUID. /// Contains the GUID that the description is registered for. /// Pointer to a WCHAR buffer that contains the description for the GUID. /// Contains the length, in characters, of the description string. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcategorymgr-registerguiddescription HRESULT // RegisterGUIDDescription( REFCLSID rclsid, REFGUID rguid, const WCHAR *pchDesc, ULONG cch ); void RegisterGUIDDescription(in Guid rclsid, in Guid rguid, [In, MarshalAs(UnmanagedType.LPWStr)] string pchDesc, uint cch); /// Removes the description for a GUID from the Windows registry. /// Contains the CLSID of the text service that owns the GUID. /// Contains the GUID that the description is removed for. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcategorymgr-unregisterguiddescription HRESULT // UnregisterGUIDDescription( REFCLSID rclsid, REFGUID rguid ); void UnregisterGUIDDescription(in Guid rclsid, in Guid rguid); /// Obtains the description of the specified GUID from the Windows registry. /// Specifies the GUID to obtain the description for. /// /// /// Pointer to a BSTR value that receives the description string. Allocate using SysAllocString. The caller must free /// this memory using SysFreeString when it is no longer required. /// /// /// Pointer to a BSTR value that receives the description string. This must be allocated using SysAllocString. The /// caller must free this memory using SysFreeString when it is no longer required. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcategorymgr-getguiddescription HRESULT // GetGUIDDescription( REFGUID rguid, BSTR *pbstrDesc ); [return: MarshalAs(UnmanagedType.BStr)] string GetGUIDDescription(in Guid rguid); /// Enters a DWORD value for a GUID previously registered in the Windows registry. /// Contains the CLSID of the text service that owns the GUID. /// Contains the GUID that the DWORD is registered for. /// Contains the DWORD value registered for the GUID. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcategorymgr-registerguiddword HRESULT RegisterGUIDDWORD( // REFCLSID rclsid, REFGUID rguid, DWORD dw ); void RegisterGUIDDWORD(in Guid rclsid, in Guid rguid, uint dw); /// Removes the DWORD value for a GUID from the Windows registry. /// Contains the CLSID of the text service that owns the GUID. /// Contains the GUID that the DWORD is removed for. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcategorymgr-unregisterguiddword HRESULT // UnregisterGUIDDWORD( REFCLSID rclsid, REFGUID rguid ); void UnregisterGUIDDWORD(in Guid rclsid, in Guid rguid); /// Obtains the DWORD value of the specified GUID from the Windows registry. /// Specifies the address of the GUID for which to get the value. /// Pointer to the DWORD variable that receives the value of the GUID. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcategorymgr-getguiddword HRESULT GetGUIDDWORD( REFGUID // rguid, DWORD *pdw ); uint GetGUIDDWORD(in Guid rguid); /// Adds a GUID to the internal table and obtains an atom for the GUID. /// Contains the GUID to obtain the identifier for. /// Pointer to a TfGuidAtom value that receives the identifier of the GUID. /// /// Identical GUID values receive identical TfGuidAtom values. /// A TfGuidAtom value is only valid within the process that ITfCategoryMgr::RegisterGUID is called from. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcategorymgr-registerguid HRESULT RegisterGUID( REFGUID // rguid, TfGuidAtom *pguidatom ); TfGuidAtom RegisterGUID(in Guid rguid); /// Obtains a GUID from the internal table using its atom. /// Contains a TfGuidAtom value that specifies the GUID to obtain. /// /// Pointer to a GUID value that receives the GUID for the specified atom. Receives GUID_NULL if the GUID /// for the atom cannot be found. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcategorymgr-getguid HRESULT GetGUID( TfGuidAtom // guidatom, GUID *pguid ); Guid GetGUID([In] TfGuidAtom guidatom); /// Determines whether the specified atom represents the specified GUID in the internal table. /// Specifies an atom that represents a GUID in the internal table. /// Specifies the address of the GUID to compare with the atom in the internal table. /// Pointer to a Boolean variable that receives an indication of whether the atom represents the GUID. /// /// If the atom specified by the guidatom parameter represents the GUID specified by the rguid parameter, the pfEqual /// parameter receives a nonzero value. Otherwise, the pfEqual parameter receives zero. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcategorymgr-isequaltfguidatom HRESULT IsEqualTfGuidAtom( // TfGuidAtom guidatom, REFGUID rguid, BOOL *pfEqual ); [return: MarshalAs(UnmanagedType.Bool)] bool IsEqualTfGuidAtom([In] TfGuidAtom guidatom, in Guid rguid); } /// /// The ITfCleanupContextDurationSink interface is implemented by a text service to receive notifications when a context /// cleanup operation is performed. This notification sink is installed by calling ITfSourceSingle::AdviseSingleSink with IID_ITfCleanupContextDurationSink. /// /// /// A context cleanup occurs when: /// /// /// /// The text service is deactivated while a context is still on the context stack. This can occur when the active text service is /// changed or when the active language changes while the text service is active. /// /// /// /// ITfThreadMgr::Deactivate is called while a context is still on the context stack. /// /// /// /// A text service can use the notifications of this interface to prevent itself from performing any context initialization during /// the context cleanup operation. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nn-msctf-itfcleanupcontextdurationsink [PInvokeData("msctf.h", MSDNShortId = "NN:msctf.ITfCleanupContextDurationSink")] [ComImport, Guid("45C35144-154E-4797-BED8-D33AE7BF8794"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface ITfCleanupContextDurationSink { /// Called when a context cleanup operation is about to begin. /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// A context cleanup occurs when: /// /// /// /// The text service is deactivated while a context is still on the context stack. This can occur when the active text service /// is changed or when the active language changes while the text service is active. /// /// /// /// ITfThreadMgr::Deactivate is called while a context is still on the context stack. /// /// /// /// ITfCleanupContextDurationSink::OnStartCleanupContext is called just before the TSF manager begins making /// ITfCleanupContextSink::OnCleanupContext notifications. When all of the OnCleanupContext notifications complete, the TSF /// manager calls OnEndCleanupContext. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcleanupcontextdurationsink-onstartcleanupcontext HRESULT OnStartCleanupContext(); [PreserveSig] HRESULT OnStartCleanupContext(); /// Called when a context cleanup operation completes. /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// A context cleanup occurs when: /// /// /// /// The text service is deactivated while a context is still on the context stack. This can occur when the active text service /// is changed or when the active language changes while the text service is active. /// /// /// /// ITfThreadMgr::Deactivate is called while a context is still on the context stack. /// /// /// /// ITfCleanupContextDurationSink::OnStartCleanupContext is called just before the TSF manager begins making /// ITfCleanupContextSink::OnCleanupContext notifications. When all of the OnCleanupContext notifications complete, the TSF /// manager calls OnEndCleanupContext. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcleanupcontextdurationsink-onendcleanupcontext HRESULT OnEndCleanupContext(); [PreserveSig] HRESULT OnEndCleanupContext(); } /// /// The ITfCleanupContextSink interface is implemented by a text service to receive notifications when a context cleanup /// operation occurs. This notification sink is installed by calling ITfSourceSingle::AdviseSingleSink with IID_ITfCleanupContextSink. /// /// /// A context cleanup occurs when: /// /// /// /// The text service is deactivated while a context is still on the context stack. This can occur when the active text service is /// changed or when the active language changes while the text service is active. /// /// /// /// ITfThreadMgr::Deactivate is called while a context is still on the context stack. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nn-msctf-itfcleanupcontextsink [PInvokeData("msctf.h", MSDNShortId = "NN:msctf.ITfCleanupContextSink")] [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("01689689-7ACB-4E9B-AB7C-7EA46B12B522")] public interface ITfCleanupContextSink { /// Called during a context cleanup operation. /// /// Contains a TfEditCookie value that identifies the edit context cleaned up. The edit context is guaranteed to have a /// read/write lock. /// /// Pointer to an ITfContext interface that represents the context cleaned up. /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// A context cleanup occurs when: /// /// /// /// The text service is deactivated while a context is still on the context stack. This can occur when the active text service /// is changed or when the active language changes while the text service is active. /// /// /// /// ITfThreadMgr::Deactivate is called while a context is still on the context stack. /// /// /// /// ITfCleanupContextDurationSink::OnStartCleanupContext is called just before the TSF manager begins making /// ITfCleanupContextSink::OnCleanupContext notifications. When all of the OnCleanupContext notifications complete, the TSF /// manager calls OnEndCleanupContext. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcleanupcontextsink-oncleanupcontext HRESULT // OnCleanupContext( TfEditCookie ecWrite, ITfContext *pic ); [PreserveSig] HRESULT OnCleanupContext([In] TfEditCookie ecWrite, [In] ITfContext pic); } /// /// The ITfClientId interface is implemented by the TSF manager. This interface is used to obtain a client identifier for TSF /// objects. An instance of this interface is obtained by querying the thread manager with IID_ITfClientId. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nn-msctf-itfclientid [PInvokeData("msctf.h", MSDNShortId = "NN:msctf.ITfClientId")] [ComImport, Guid("D60A7B49-1B9F-4BE2-B702-47E9DC05DEC3"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface ITfClientId { /// Obtains a client identifier for a CLSID. /// CLSID to obtain the client identifier for. /// Pointer to a TfClientId value that receives the client identifier. /// /// An application obtains its client identifier by calling ITfThreadMgr::Activate and a text service receives its client /// identifier in its ITfTextInputProcessor::Activate method. ITfClientId::GetClientId enables TSF objects that do not /// fit either of these categories to obtain their own client identifier. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfclientid-getclientid HRESULT GetClientId( REFCLSID // rclsid, TfClientId *ptid ); TfClientId GetClientId(in Guid rclsid); } /// /// /// The ITfCompartment interface is implemented by the TSF manager and is used by clients (applications and text services) to /// obtain and set data in a TSF compartment. /// /// /// A client also uses this interface to obtain an ITfSource interface that is used to install an ITfCompartmentEventSink /// compartment change notification sink. The client calls ITfCompartment::QueryInterface with IID_ITfSource to obtain the /// ITfSource interface. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nn-msctf-itfcompartment [PInvokeData("msctf.h", MSDNShortId = "NN:msctf.ITfCompartment")] [ComImport, Guid("BB08F7A9-607A-4384-8623-056892B64371"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface ITfCompartment { /// Sets the data for a compartment. /// Contains a TfClientId value that identifies the client. /// /// Pointer to a VARIANT structure that contains the data to be set. Only VT_I4, VT_UNKNOWN and VT_BSTR data types are allowed. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcompartment-setvalue HRESULT SetValue( TfClientId tid, // const VARIANT *pvarValue ); void SetValue([In] TfClientId tid, [In, MarshalAs(UnmanagedType.Struct)] in object pvarValue); /// Obtains the data for a compartment. /// /// Pointer to a VARIANT structure that receives the data. This receives VT_EMPTY if the compartment has no value. The /// caller must free this data when it is no longer required by calling VariantClear. /// /// /// The caller must recognize the supplied data format in order to use the data. The compartment installer must publish the data /// format to enable other clients to use it. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcompartment-getvalue HRESULT GetValue( VARIANT // *pvarValue ); [return: MarshalAs(UnmanagedType.Struct)] object GetValue(); } /// /// The ITfCompartmentEventSink interface is implemented by a client (application or text service) and used by the TSF /// manager to notify the client when compartment data changes. This notification sink is installed by obtaining an ITfSource /// interface from the ITfCompartment object and calling ITfSource::AdviseSink with IID_ITfCompartmentEventSink and a pointer to the /// ITfCompartmentEventSink object. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nn-msctf-itfcompartmenteventsink [PInvokeData("msctf.h", MSDNShortId = "NN:msctf.ITfCompartmentEventSink")] [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("743ABD5F-F26D-48DF-8CC5-238492419B64")] public interface ITfCompartmentEventSink { /// Called when compartment data changes. /// Contains a GUID that identifies the compartment that changed. /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// When this method is called, the data has changed. The new data can be obtained at this time by calling ITfCompartment::GetValue. /// ITfCompartment::SetValue will return E_UNEXPECTED if called from within this notification. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcompartmenteventsink-onchange HRESULT OnChange( REFGUID // rguid ); [PreserveSig] HRESULT OnChange(in Guid rguid); } /// /// The ITfCompartmentMgr interface is implemented by the TSF manager and used by clients (applications and text services) to /// obtain and manipulate TSF compartments. /// /// /// /// The set of compartments that this interface is responsible for depends upon how the interface was obtained. An instance of this /// interface can be obtained in one of the following ways. For more information, see Compartments. /// /// /// /// ITfThreadMgr::GetGlobalCompartment - Obtains the global compartment manager. /// /// /// /// ITfThreadMgr::QueryInterface with IID_ITfCompartmentMgr - Obtains the compartment manager for this specific thread manager. /// /// /// /// /// ITfDocumentMgr::QueryInterface with IID_ITfCompartmentMgr - Obtains the compartment manager for this specific document manager. /// /// /// /// ITfContext::QueryInterface with IID_ITfCompartmentMgr - Obtains the compartment manager for this specific context. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nn-msctf-itfcompartmentmgr [PInvokeData("msctf.h", MSDNShortId = "NN:msctf.ITfCompartmentMgr")] [ComImport, Guid("7DCF57AC-18AD-438B-824D-979BFFB74B7C"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface ITfCompartmentMgr { /// Obtains the compartment object for a specified compartment. /// Contains a GUID that identifies the compartment. /// Pointer to an ITfCompartment interface pointer that receives the compartment object. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcompartmentmgr-getcompartment HRESULT GetCompartment( // REFGUID rguid, ITfCompartment **ppcomp ); ITfCompartment GetCompartment(in Guid rguid); /// Removes the specified compartment. /// Contains a TfClientId value that identifies the client. /// Contains a GUID that identifies the compartment. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcompartmentmgr-clearcompartment HRESULT // ClearCompartment( TfClientId tid, REFGUID rguid ); void ClearCompartment([In] TfClientId tid, in Guid rguid); /// /// The ITfCompartmentMgr::EnumCompartments method obtains an enumerator that contains the GUID of the compartments /// within the compartment manager. /// /// Pointer to an IEnumGUID interface pointer that receives the enumerator object. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcompartmentmgr-enumcompartments HRESULT // EnumCompartments( IEnumGUID **ppEnum ); IEnumGUID EnumCompartments(); } /// /// The ITfComposition interface is implemented by the TSF manager and is used by a text service to obtain data about and /// terminate a composition. An instance of this interface is provided by the ITfContextComposition::StartComposition method. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nn-msctf-itfcomposition [PInvokeData("msctf.h", MSDNShortId = "NN:msctf.ITfComposition")] [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("20168D64-5A8F-4A5A-B7BD-CFA29F4D0FD9")] public interface ITfComposition { /// Obtains a range object that contains the text covered by the composition. /// /// Pointer to an ITfRange interface pointer that receives the range object. It is possible that the range will have zero length. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcomposition-getrange HRESULT GetRange( ITfRange // **ppRange ); ITfRange GetRange(); /// Moves the start anchor of a composition. /// Contains an edit cookie that identifies the edit context obtained from ITfEditSession::DoEditSession. /// /// Pointer to an ITfRange object that contains the new start anchor position. The start anchor of the context will be moved to /// the start anchor of this range. This method fails if the start anchor of this range is positioned beyond the end anchor of /// the composition. /// /// /// This method causes the GUID_PROP_COMPOSING property to be removed from any text removed from the composition. Likewise, the /// GUID_PROP_COMPOSING property will also be added to any text added to the composition. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcomposition-shiftstart HRESULT ShiftStart( TfEditCookie // ecWrite, ITfRange *pNewStart ); void ShiftStart([In] TfEditCookie ecWrite, [In] ITfRange pNewStart); /// Moves the end anchor of a composition. /// Contains an edit cookie that identifies the edit context obtained from ITfEditSession::DoEditSession. /// /// Pointer to an ITfRange object that contains the new end anchor position. The end anchor of the context will be moved to the /// end anchor of this range. This method fails if the end anchor of this range is positioned prior to the start anchor of the composition. /// /// /// This method causes the GUID_PROP_COMPOSING property to be removed from any text removed from the composition. Likewise, the /// GUID_PROP_COMPOSING property is also added to any text added to the composition. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcomposition-shiftend HRESULT ShiftEnd( TfEditCookie // ecWrite, ITfRange *pNewEnd ); void ShiftEnd([In] TfEditCookie ecWrite, [In] ITfRange pNewEnd); /// Terminates a composition. /// Contains an edit cookie that identifies the edit context obtained from ITfEditSession::DoEditSession. /// /// /// This method does not release the composition object, but the ITfComposition methods will fail with E_UNEXPECTED after this /// method is called. /// /// Context owners should use the ITFContextOwnerCompositionServices::TerminateComposition method to terminate a composition. /// This method causes the GUID_PROP_COMPOSING property to be removed from the text covered by the composition. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcomposition-endcomposition HRESULT EndComposition( // TfEditCookie ecWrite ); void EndComposition([In] TfEditCookie ecWrite); } /// /// The ITfCompositionSink interface is implemented by a text service to receive a notification when a composition is /// terminated. This advise sink is installed by passing a pointer to this interface when the composition is started with the /// ITfContextComposition::StartComposition method. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nn-msctf-itfcompositionsink [PInvokeData("msctf.h", MSDNShortId = "NN:msctf.ITfCompositionSink")] [ComImport, Guid("A781718C-579A-4B15-A280-32B8577ACC5E"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface ITfCompositionSink { /// Called when a composition is terminated. /// /// Contains a TfEditCookie value that identifies the edit context. This is the same value passed for ecWrite in the call to ITfContextComposition::StartComposition. /// /// Pointer to the ITfComposition object terminated. /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// There is no required action for the TSF text service when this method is called. The TSF text service can use this /// notification to revert partially composed text into readable text or erase the composition entirely. The TSF manager will /// automatically clear the GUID_PROP_COMPOSING property value over the affected text. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcompositionsink-oncompositionterminated HRESULT // OnCompositionTerminated( TfEditCookie ecWrite, ITfComposition *pComposition ); [PreserveSig] HRESULT OnCompositionTerminated([In] TfEditCookie ecWrite, [In] ITfComposition pComposition); } /// /// The ITfCompositionView interface is implemented by the TSF manager and used by an application to obtain data about a /// composition view. An instance of this interface is provided by one of the ITfContextOwnerCompositionSink methods. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nn-msctf-itfcompositionview [PInvokeData("msctf.h", MSDNShortId = "NN:msctf.ITfCompositionView")] [ComImport, Guid("D7540241-F9A1-4364-BEFC-DBCD2C4395B7"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface ITfCompositionView { /// Obtains the class identifier of the text service that created the composition object. /// Pointer to a CLSID that receives the class identifier of the text service that owns the composition. /// This method can be used to enable a text service to filter compositions that it does not own. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcompositionview-getownerclsid HRESULT GetOwnerClsid( // CLSID *pclsid ); Guid GetOwnerClsid(); /// Obtains a range object that contains the text covered by the composition. /// /// Pointer to an ITfRange interface pointer that receives the range object. It is possible that the range will have zero length. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcompositionview-getrange HRESULT GetRange( ITfRange // **ppRange ); ITfRange GetRange(); } /// /// The ITfConfigureSystemKeystrokeFeed interface is implemented by the TSF manager to enable and disable the processing of /// keystrokes. This interface is obtained by calling the TSF manager's ITfThreadMgr::QueryInterface with IID_ITfConfigureSystemKeystrokeFeed. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nn-msctf-itfconfiguresystemkeystrokefeed [PInvokeData("msctf.h", MSDNShortId = "NN:msctf.ITfConfigureSystemKeystrokeFeed")] [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("0D2C969A-BC9C-437C-84EE-951C49B1A764")] public interface ITfConfigureSystemKeystrokeFeed { /// Prevents the TSF manager from processing keystrokes. /// /// /// By default, the TSF manager will process keystrokes and pass them to the text services. An application prevents this by /// calling this method. Typically, this method is called when text service input is inappropriate, for example when a menu is displayed. /// /// Calls to this method are cumulative, so every call to this method requires a subsequent call to ITfConfigureSystemKeystrokeFeed::EnableSystemKeystrokeFeed. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfconfiguresystemkeystrokefeed-disablesystemkeystrokefeed // HRESULT DisableSystemKeystrokeFeed(); void DisableSystemKeystrokeFeed(); /// Enables the TSF manager to process keystrokes after being disabled by DisableSystemKeystrokeFeed. /// /// /// By default, the TSF manager will process keystrokes and pass them to the text services. An application prevents this by /// calling DisableSystemKeystrokeFeed . /// /// /// Calls to DisableSystemKeystrokeFeed are cumulative, so every call to DisableSystemKeystrokeFeed requires a /// subsequent call to EnableSystemKeystrokeFeed. Calling EnableSystemKeystrokeFeed will not enable keystroke /// processing if DisableSystemKeystrokeFeed is called more than once. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfconfiguresystemkeystrokefeed-enablesystemkeystrokefeed // HRESULT EnableSystemKeystrokeFeed(); void EnableSystemKeystrokeFeed(); } /// /// The ITfContext interface is implemented by the TSF manager and used by applications and text services to access an edit context. /// /// /// /// An edit context object is created by calling ITfDocumentMgr::CreateContext. Often, a text service uses the currently active edit /// context. The currently active edit context is the edit context at the top of the stack of the active document manager. /// /// Examples /// /// ///GetFocus(&pFocusDoc); /// if(SUCCEEDED(hr)) /// { /// ITfContext *pContext; /// /// hr = pFocusDoc->GetTop(&pContext); /// if(SUCCEEDED(hr)) /// { /// //Use the context. /// /// pContext->Release(); /// } /// /// pFocusDoc->Release(); /// }]]> /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nn-msctf-itfcontext [PInvokeData("msctf.h", MSDNShortId = "NN:msctf.ITfContext")] [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("AA80E7FD-2021-11D2-93E0-0060B067B86E")] public interface ITfContext { /// Obtains access to the document text and properties. /// Contains a TfClientId value that identifies the client to establish the edit session with. /// Pointer to an ITfEditSession interface called to perform the edit session. /// /// Contains one or more of the following values. /// /// /// Value /// Meaning /// /// /// TF_ES_ASYNCDONTCARE /// /// The edit session can occur synchronously or asynchronously, at the discretion of the TSF manager. The manager will attempt /// to schedule a synchronous edit session for improved performance. This value cannot be combined with the TF_ES_ASYNC or /// TF_ES_SYNC values. /// /// /// /// TF_ES_SYNC /// /// The edit session must be synchronous or the request will fail (with TF_E_SYNCHRONOUS). This flag should only be used in /// documented situations (such as keystroke handling) where it can be expected to succeed. Otherwise the call will likely fail. /// This value cannot be combined with the TF_ES_ASYNCDONTCARE or TF_ES_ASYNC values. /// /// /// /// TF_ES_READ /// Requests read-only access to the context. /// /// /// TF_ES_READWRITE /// Requests read/write access to the context. /// /// /// TF_ES_ASYNC /// /// The edit session must be asynchronous or the request fails. This value cannot be combined with the TF_ES_ASYNCDONTCARE or /// TF_ES_SYNC values. /// /// /// /// /// /// /// Address of an HRESULT value that receives the result of the edit session request. The value received depends upon the /// type of edit session requested. /// /// /// /// If an asynchronous edit session is requested and can be established, receives TF_S_ASYNC. /// /// /// If a synchronous edit session is requested and cannot be established, receives TF_E_SYNCHRONOUS. /// /// /// If the TF_ES_READWRITE flag is specified and the document is read-only, receives TS_E_READONLY. /// /// /// If a synchronous edit session is established, receives the return value of the ITfEditSession::DoEditSession. /// /// /// /// /// /// Pending asynchronous edit sessions are processed in the order received. Synchronous edit sessions are processed before any /// pending asynchronous edit sessions. /// /// /// A text service can request an edit session within the context of an existing edit session, provided a write access session /// is not requested within a read-only session. Calls to this method within the context of an edit session established by /// another text service will fail with TF_E_LOCKED. /// /// A synchronous read/write request will fail if made when processing one of the following notifications. /// /// /// ITfTextEditSink::OnEndEdit /// /// /// ITfTextLayoutSink::OnLayoutChange /// /// /// ITfStatusSink::OnStatusChange /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcontext-requesteditsession HRESULT RequestEditSession( // TfClientId tid, ITfEditSession *pes, DWORD dwFlags, HRESULT *phrSession ); void RequestEditSession([In] TfClientId tid, [In] ITfEditSession pes, [In] TF_ES dwFlags, out HRESULT phrSession); /// Determines if a client has a read/write lock on the context. /// Contains a TfClientID value that identifies the client. /// /// Pointer to a BOOL that receives a nonzero value if the client has a read/write lock on the context. Receives zero if /// the client does not have an edit session or has a read-only edit session. /// /// A client uses this method, from inside a notification callback, to determine if it must make the change. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcontext-inwritesession HRESULT InWriteSession( // TfClientId tid, BOOL *pfWriteSession ); [return: MarshalAs(UnmanagedType.Bool)] bool InWriteSession([In] TfClientId tid); /// Obtains the selection within the document. /// Contains an edit cookie that identifies the edit session. This is the value passed to ITfEditSession::DoEditSession. /// /// Specifies the zero-based index of the first selection to obtain. Use TF_DEFAULT_SELECTION to obtain the default selection. /// If TF_DEFAULT_SELECTION is used, only one selection is obtained. /// /// Specifies the maximum number of selections to obtain. /// /// An array of TF_SELECTION structures that receives the data for each selection. The array must be able to hold at least /// ulCount elements. /// /// Pointer to a ULONG value that receives the number of selections obtained. /// /// /// A selection is a highlighted range of text, or an insertion point if the range is empty, that identifies the user focus area /// within a document. /// /// /// If this method is successful, the caller must release the range member of all TF_SELECTION structures obtained. /// /// /// Normally, a context only supports a single selection. It is possible, however, for a context to support multiple, /// simultaneous selections. This method can be used to obtain multiple selections. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcontext-getselection HRESULT GetSelection( TfEditCookie // ec, ULONG ulIndex, ULONG ulCount, TF_SELECTION *pSelection, ULONG *pcFetched ); void GetSelection([In] TfEditCookie ec, uint ulIndex, uint ulCount, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] TF_SELECTION[] pSelection, [NullAllowed] out uint pcFetched); /// Sets the selection within the document. /// Contains an edit cookie that identifies the edit session. This is the value passed to ITfEditSession::DoEditSession. /// Specifies the number of selections in the pSelection array. /// An array of TF_SELECTION structures that contain the information for each selection. /// /// /// A selection is a span of highlighted text, or an insertion point if the span is empty, identifying the user focus area /// within a document. Some documents are capable of having multiple selections. There can only be one zero-length selection in /// pSelection as it represents the position of the document caret. /// /// /// If an application must adjust the text covered by a selection, it should wait until the caller releases the lock. However, /// applications can adjust any of the style members of the TF_SELECTION structures while still returning S_OK. /// /// /// The caller can set the fInterimChar flag only if one selection is set. In this case, the selection should span /// exactly one character and the ase member of the TF_SELECTION structure is set to TFAE_NONE. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcontext-setselection HRESULT SetSelection( TfEditCookie // ec, ULONG ulCount, const TF_SELECTION *pSelection ); void SetSelection([In] TfEditCookie ec, uint ulCount, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] TF_SELECTION[] pSelection); /// Obtains a range of text positioned at the beginning of the document. /// Contains an edit cookie that identifies the edit session. This is the value passed to ITfEditSession::DoEditSession. /// Pointer to an ITfRange interface that receives an empty range positioned at the start of the document. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcontext-getstart HRESULT GetStart( TfEditCookie ec, // ITfRange **ppStart ); ITfRange GetStart([In] TfEditCookie ec); /// Obtains a range of text positioned at the end of the document. /// Contains an edit cookie that identifies the edit session. This is the value passed to ITfEditSession::DoEditSession. /// Pointer to an ITfRange interface pointer that receives an empty range positioned at the end of the document. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcontext-getend HRESULT GetEnd( TfEditCookie ec, ITfRange // **ppEnd ); ITfRange GetEnd([In] TfEditCookie ec); /// Obtains the active view for the context. /// Pointer to an ITfContextView interface pointer that receives a reference to the active view. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcontext-getactiveview HRESULT GetActiveView( // ITfContextView **ppView ); ITfContextView GetActiveView(); /// This method has no parameters. /// This method does not return a value. // https://docs.microsoft.com/en-us/windows/win32/tsf/itfcontext-enumviews void (); IEnumTfContextViews EnumViews(); /// Obtains the document status. /// Pointer to a TF_STATUS structure that receives the document status data. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcontext-getstatus HRESULT GetStatus( TF_STATUS *pdcs ); TS_STATUS GetStatus(); /// Obtains a text property. /// /// Specifies the property identifier. This can be a custom identifier or one of the predefined property identifiers. /// /// Pointer to an ITfProperty interface pointer that receives the property object. /// /// An application or text service can define unique properties identified by a GUID. Properties are stored as VARIANT data, so /// the caller must recognize the format and meaning of unique properties to be able to use them. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcontext-getproperty HRESULT GetProperty( REFGUID // guidProp, ITfProperty **ppProp ); ITfProperty GetProperty(in Guid guidProp); /// Obtains an application property. /// /// Specifies the property identifier. This can be a custom identifier or one of the predefined property identifiers. /// /// Pointer to an ITfReadOnlyProperty interface pointer that receives the property object. /// /// /// Applications can define unique properties identified by a GUID. Properties are stored as VARIANT data, so the caller must /// recognize the format and meaning of unique properties to be able to use them. /// /// /// Application properties differ from text properties, obtained by ITfContext::GetProperty, in that, application properties are /// maintained by the context owner and cannot be modified by a text service. Application properties can only be modified by the /// context owner. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcontext-getappproperty HRESULT GetAppProperty( REFGUID // guidProp, ITfReadOnlyProperty **ppProp ); ITfReadOnlyProperty GetAppProperty(in Guid guidProp); /// Obtains a special property that can enumerate multiple properties over multiple ranges. /// Contains an array of property identifiers that specify the properties to track. /// Contains the number of property identifiers in the prgProp array. /// /// Contains an array of application property identifiers that specify the application properties to track. /// /// Contains the number of application property identifiers in the prgAppProp array. /// Pointer to an ITfReadOnlyProperty interface pointer that receives the tracking property. /// /// /// This method is used to quickly identify ranges with consistent property values for multiple properties. While this method /// could be duplicated using only the ITfContext::GetProperty method, the TSF manager can accomplish this task more quickly. /// /// /// The property obtained by this method is a VT_UNKNOWN type. This property can be used to obtain an IEnumTfPropertyValue /// enumerator by calling the QueryInterface method with IID_IEnumTfPropertyValue. This enumerator contains property /// values specified by prgProp and prgAppProp. /// /// Examples /// /// ///TrackProperties(NULL, 0, rgGuids, 2, &pTrackProperty); /// /// // Get the selection range. /// hr = pContext->GetSelection(ec, TF_DEFAULT_SELECTION, 1, &sel, &cFetched); /// /// // Use the property from TrackProperties to get an enumeration of the ranges /// // within the selection range that have the same property values. /// hr = pTrackProperty->EnumRanges(ec, &pEnumRanges, sel.range); /// /// // Enumerate the ranges of text. /// while(pEnumRanges->Next(1, &pRangeValue, NULL) == S_OK) /// { /// VARIANT varTrackerValue; /// TF_PROPERTYVAL tfPropertyVal; /// IEnumTfPropertyValue *pEnumPropVal; /// /// // Get the values for this range of text. /// hr = pTrackProperty->GetValue(ec, pRangeValue, &varTrackerValue); /// /// // Because pTrackProperties originates from TrackProperties, /// // varTrackerValue can be identified as a VT_UNKNOWN/IEnumTfPropertyValue. /// varTrackerValue.punkVal->QueryInterface(IID_IEnumTfPropertyValue, (void **)&pEnumPropVal); /// /// while(pEnumPropVal->Next(1, &tfPropertyVal, NULL) == S_OK) /// { /// BOOL fComposingValue; /// TfGuidAtom gaDispAttrValue; /// /// // Is this the composition property? /// if (IsEqualGUID(tfPropertyVal.guidId, GUID_PROP_COMPOSING)) /// { /// fComposingValue = (BOOL)tfPropertyVal.varValue.lVal; /// } /// // Or is this the attribute property? /// else if (IsEqualGUID(tfPropertyVal.guidId, GUID_PROP_ATTRIBUTE)) /// { /// gaDispAttrValue = (TfGuidAtom)tfPropertyVal.varValue.lVal; /// } /// /// // Clear the property. /// VariantClear(&tfPropertyVal.varValue); /// } /// /// // Clear the tracker property. /// VariantClear(&varTrackerValue); /// /// // Release the property enumerator. /// pEnumPropVal->Release(); /// /// // Release the range. /// pRangeValue->Release(); /// } /// /// // Release the selection range. /// sel.range->Release();]]> /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcontext-trackproperties HRESULT TrackProperties( const // GUID **prgProp, ULONG cProp, const GUID **prgAppProp, ULONG cAppProp, ITfReadOnlyProperty **ppProperty ); ITfReadOnlyProperty TrackProperties([In, Optional] IntPtr prgProp, [In, Optional] uint cProp, [In, Optional] IntPtr prgAppProp, [In, Optional] uint cAppProp); /// Obtains a document property enumerator. /// Pointer to an IEnumTfProperties interface pointer that receives the enumerator object. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcontext-enumproperties HRESULT EnumProperties( // IEnumTfProperties **ppEnum ); IEnumTfProperties EnumProperties(); /// Obtains the document manager that contains the context. /// Pointer to an ITfDocumentMgr interface pointer that receives the document manager. /// /// If the context is not contained within a document manager, this method returns S_FALSE and ppDm is set to NULL. This /// occurs when the context is removed from the context stack through a call to ITfDocumentMgr::Pop. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcontext-getdocumentmgr HRESULT GetDocumentMgr( // ITfDocumentMgr **ppDm ); ITfDocumentMgr GetDocumentMgr(); /// Creates a backup of a range. /// Contains an edit cookie that identifies the edit session. This is the value passed to ITfEditSession::DoEditSession. /// Pointer to the ITfRange object to be backed up. /// Pointer to an ITfRangeBackup interface pointer that receives the backup of pRange. /// This method creates a copy of the range that it can use to restore the data in ITfRangeBackup::Restore. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcontext-createrangebackup HRESULT CreateRangeBackup( // TfEditCookie ec, ITfRange *pRange, ITfRangeBackup **ppBackup ); ITfRangeBackup CreateRangeBackup([In] TfEditCookie ec, [In] ITfRange pRange); } /// /// The ITfContextComposition interface is implemented by the TSF manager and is used by a text service to create and /// manipulate compositions. An instance of this interface is provided by ITfContext::QueryInterface with IID_ITfContextComposition. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nn-msctf-itfcontextcomposition [PInvokeData("msctf.h", MSDNShortId = "NN:msctf.ITfContextComposition")] [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("D40C8AAE-AC92-4FC7-9A11-0EE0E23AA39B")] public interface ITfContextComposition { /// Creates a new composition. /// Contains an edit cookie that identifies the edit context. This is obtained from ITfEditSession::DoEditSession. /// Pointer to an ITfRange object that specifies the text that the composition initially covers. /// /// Pointer to an ITfCompositionSink object that receives composition event notifications. This parameter is optional and can be /// NULL. If supplied, the object is released when the composition is terminated. /// /// /// Pointer to an ITfComposition interface pointer that receives the new composition object. This parameter receives NULL /// if the context owner rejects the composition. /// /// /// /// If the context owner has installed an context owner composition advise sink, the /// ITfContextOwnerCompositionSink::OnStartComposition method is called. If the advise sink rejects the new composition, this /// method returns S_OK but ppComposition is set to NULL. /// /// Any text covered by pCompositionRange receives the GUID_PROP_COMPOSING property. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcontextcomposition-startcomposition HRESULT // StartComposition( TfEditCookie ecWrite, ITfRange *pCompositionRange, ITfCompositionSink *pSink, ITfComposition // **ppComposition ); ITfComposition StartComposition([In] TfEditCookie ecWrite, [In] ITfRange pCompositionRange, [In, Optional] ITfCompositionSink pSink); /// Creates an enumerator object that contains all compositions in the context. /// Pointer to an IEnumITfCompositionView interface pointer that receives the enumerator object. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcontextcomposition-enumcompositions HRESULT // EnumCompositions( IEnumITfCompositionView **ppEnum ); IEnumITfCompositionView EnumCompositions(); /// Creates an enumerator object that contains all compositions that intersect a specified range of text. /// Contains an edit cookie that identifies the edit context. This is obtained from ITfEditSession::DoEditSession. /// /// Pointer to an ITfRange object that specifies the range to search. This parameter can be NULL. If this parameter is /// NULL, the enumerator will contain all compositions in the edit context. /// /// Pointer to an IEnumITfCompositionView interface pointer that receives the enumerator object. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcontextcomposition-findcomposition HRESULT // FindComposition( TfEditCookie ecRead, ITfRange *pTestRange, IEnumITfCompositionView **ppEnum ); IEnumITfCompositionView FindComposition([In] TfEditCookie ecRead, [In, Optional] ITfRange pTestRange); /// Not currently implemented. /// Not used. /// Not used. /// Not used. /// Not used. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcontextcomposition-takeownership HRESULT TakeOwnership( // TfEditCookie ecWrite, ITfCompositionView *pComposition, ITfCompositionSink *pSink, ITfComposition **ppComposition ); ITfComposition TakeOwnership([In] TfEditCookie ecWrite, [In] ITfCompositionView pComposition, [In] ITfCompositionSink pSink); } /// /// /// The ITfContextKeyEventSink interface is implemented by a text service to receive keyboard event notifications that occur /// in an input context. This keyboard event sink differs from the ITfKeyEventSink keyboard event sink in that the keyboard events /// are passed to ITfContextKeyEventSink after having been preprocessed by the ITfKeyEventSink event sink. Preserved /// key events and filtered key events are not passed to the ITfContextKeyEventSink event sink. /// /// This event sink is installed by ITfSource::AdviseSink with IID_ITfContextKeyEventSink. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nn-msctf-itfcontextkeyeventsink [PInvokeData("msctf.h", MSDNShortId = "NN:msctf.ITfContextKeyEventSink")] [ComImport, Guid("0552BA5D-C835-4934-BF50-846AAA67432F"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface ITfContextKeyEventSink { /// Called when a key down event occurs. /// /// Specifies the virtual-key code of the key. For more information about this parameter, see the wParam parameter in WM_KEYDOWN. /// /// /// Specifies the repeat count, scan code, extended-key flag, context code, previous key-state flag, and transition-state flag /// of the key. For more information about this parameter, see the lParam parameter in WM_KEYDOWN. /// /// /// Pointer to a BOOL value that, on exit, indicates if the key event is handled. If this value receives TRUE, the key /// event is handled. If this value is FALSE, the key event is not handled. /// /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcontextkeyeventsink-onkeydown HRESULT OnKeyDown( WPARAM // wParam, LPARAM lParam, BOOL *pfEaten ); [PreserveSig] HRESULT OnKeyDown([In] WPARAM wParam, [In] LPARAM lParam, [Out, MarshalAs(UnmanagedType.Bool)] out bool pfEaten); /// Called when a key up event occurs. /// /// Specifies the virtual-key code of the key. For more information about this parameter, see the wParam parameter in WM_KEYUP. /// /// /// Specifies the repeat count, scan code, extended-key flag, context code, previous key-state flag, and transition-state flag /// of the key. For more information about this parameter, see the lParam parameter in WM_KEYUP. /// /// /// Pointer to a BOOL value that, on exit, indicates if the key event is handled. If this value receives TRUE, the key /// event is handled. If this value receives FALSE, the key event is not handled. /// /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcontextkeyeventsink-onkeyup HRESULT OnKeyUp( WPARAM // wParam, LPARAM lParam, BOOL *pfEaten ); [PreserveSig] HRESULT OnKeyUp([In] WPARAM wParam, [In] LPARAM lParam, [Out, MarshalAs(UnmanagedType.Bool)] out bool pfEaten); /// Called to determine if a text service will handle a key down event. /// /// Specifies the virtual-key code of the key. For more information about this parameter, see the wParam parameter in WM_KEYDOWN. /// /// /// Specifies the repeat count, scan code, extended-key flag, context code, previous key-state flag, and transition-state flag /// of the key. For more information about this parameter, see the lParam parameter in WM_KEYDOWN. /// /// /// Pointer to a BOOL value that, on exit, indicates if the key event is handled. If this value receives TRUE, the key /// event is handled. If this value is FALSE, the key event is not handled. /// /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcontextkeyeventsink-ontestkeydown HRESULT OnTestKeyDown( // WPARAM wParam, LPARAM lParam, BOOL *pfEaten ); [PreserveSig] HRESULT OnTestKeyDown([In] WPARAM wParam, [In] LPARAM lParam, [Out, MarshalAs(UnmanagedType.Bool)] out bool pfEaten); /// Called to determine if a text service will handle a key up event. /// /// Specifies the virtual-key code of the key. For more information about this parameter, see the wParam parameter in WM_KEYUP. /// /// /// Specifies the repeat count, scan code, extended-key flag, context code, previous key-state flag, and transition-state flag /// of the key. For more information about this parameter, see the lParam parameter in WM_KEYUP. /// /// /// Pointer to a BOOL value that, on exit, indicates if the key event is handled. If this value receives TRUE, the key /// event is handled. If this value receives FALSE, the key event would is not handled. /// /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcontextkeyeventsink-ontestkeyup HRESULT OnTestKeyUp( // WPARAM wParam, LPARAM lParam, BOOL *pfEaten ); [PreserveSig] HRESULT OnTestKeyUp([In] WPARAM wParam, [In] LPARAM lParam, [Out, MarshalAs(UnmanagedType.Bool)] out bool pfEaten); } /// /// The ITfContextOwner interface is implemented by an application or a text service to receive text input without having a /// text store. An instance of this interface is obtained when the application calls the ITfSource::AdviseSink method. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nn-msctf-itfcontextowner [PInvokeData("msctf.h", MSDNShortId = "NN:msctf.ITfContextOwner")] [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("AA80E80C-2021-11D2-93E0-0060B067B86E")] public interface ITfContextOwner { /// /// The ITfContextOwner::GetACPFromPoint method converts a point in screen coordinates to an application character position. /// /// Pointer to the POINT structure with the screen coordinates of the point. /// /// /// Specifies the character position to return based upon the screen coordinates of the point relative to a character bounding /// box. By default, the character position returned is the character bounding box containing the screen coordinates of the /// point. If the point is outside a character's bounding box, the method returns NULL or TF_E_INVALIDPOINT. /// /// /// If the GXFPF_ROUND_NEAREST flag is specified for this parameter and the screen coordinates of the point are contained in a /// character bounding box, the character position returned is the bounding edge closest to the screen coordinates of the point. /// /// /// If the GXFPF_NEAREST flag is specified for this parameter and the screen coordinates of the point are not contained in a /// character bounding box, the closest character position is returned. /// /// The bit flags can be combined. /// /// Receives the character position that corresponds to the screen coordinates of the point /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// TS_E_INVALIDPOINT /// The ptScreen parameter is not within the bounding box of any character. /// /// /// TS_E_NOLAYOUT /// The application has not calculated a text layout. /// /// /// /// /// Use the illustration to determine the character position returned based on the flags used in the dwFlags parameter. /// Point 1 /// /// /// /// Default-- pacp = 0 --The screen coordinates of the point is inside the character bounding box of Character Position 0. /// /// /// /// /// GXPF_ROUND_NEAREST-- pacp = 1 --The screen coordinates of the point is closest to Range Position 1 which is the starting /// range position of Character Position 1. /// /// /// /// /// GXPF_NEAREST-- pacp = 0 --The default behavior occurs because the point lies within the character bounding box of Character /// Position 0. /// /// /// /// Point 2 /// /// /// Default-- hr = TF_E_INVALIDPOINT --The screen coordinates of the point is outside a character bounding box. /// /// /// /// GXPF_ROUND_NEAREST-- hr = TF_E_INVALIDPOINT --The default behavior occurs because the screen coordinates of the point is /// outside a character bounding box. /// /// /// /// /// GXPF_NEAREST-- pacp = 1 --The closest character position to the screen coordinates of the point is Character Position 1. /// /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcontextowner-getacpfrompoint HRESULT GetACPFromPoint( // const POINT *ptScreen, DWORD dwFlags, LONG *pacp ); [PreserveSig] HRESULT GetACPFromPoint(in POINT ptScreen, GXFPF dwFlags, out int pacp); /// /// The ITfContextOwner::GetTextExt method returns the bounding box, in screen coordinates, of the text at a specified /// character position. The caller must have a read-only lock on the document before calling this method. /// /// Specifies the starting character position of the text to get in the document. /// Specifies the ending character position of the text to get in the document. /// Receives the bounding box, in screen coordinates, of the text at the specified character positions. /// /// Receives the Boolean value that specifies if the text in the bounding box has been clipped. If this parameter is /// TRUE, the bounding box contains clipped text and does not include the entire requested range of text. The bounding /// box is clipped because of the requested range is not visible. /// /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// TS_E_INVALIDARG /// The specified start and end character positions are equal. /// /// /// TS_E_INVALIDPOS /// The range specified by the acpStart and acpEnd parameters extends past the end of the document or the top of the document. /// /// /// TS_E_NOLAYOUT /// The application has not calculated a text layout. /// /// /// TS_E_NOLOCK /// The caller does not have a read-only lock on the document. /// /// /// /// /// If the document window is minimized, or if the specified text is not currently visible, the method returns S_OK with the prc /// parameter set to {0,0,0,0}. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcontextowner-gettextext HRESULT GetTextExt( LONG // acpStart, LONG acpEnd, RECT *prc, BOOL *pfClipped ); [PreserveSig] HRESULT GetTextExt(int acpStart, int acpEnd, out RECT prc, [Out, MarshalAs(UnmanagedType.Bool)] out bool pfClipped); /// /// The ITfContextOwner::GetScreenExt method returns the bounding box, in screen coordinates, of the display surface /// where the text stream is rendered. /// /// Receives the bounding box screen coordinates of the display surface of the document. /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// /// /// If the text is not currently displayed, for example if the document window is minimized, prc is set to { 0, 0, 0, 0 }. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcontextowner-getscreenext HRESULT GetScreenExt( RECT // *prc ); [PreserveSig] HRESULT GetScreenExt(out RECT prc); /// /// The ITfContextOwner::GetStatus method obtains the status of a document. The document status is returned through the /// TS_STATUS structure. /// /// Receives the TS_STATUS structure that contains the document status. Cannot be NULL. /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcontextowner-getstatus HRESULT GetStatus( TF_STATUS // *pdcs ); [PreserveSig] HRESULT GetStatus(out TS_STATUS pdcs); /// The ITfContextOwner::GetWnd method returns the handle to a window that corresponds to the current document. /// /// Receives a pointer to the handle of the window that corresponds to the current document. This parameter can be NULL /// if the document does not have the corresponding handle to the window. /// /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// /// /// A document might not have a corresponding window handle if the document is in memory but not displayed on the screen or if /// the document is a windowless control and the control does not know the window handle of the owner of the windowless /// controls. Callers cannot assume that the phwnd parameter will receive a non- NULL value even if the method is /// successful. Callers can also receive a NULL value for the phwnd parameter. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcontextowner-getwnd HRESULT GetWnd( HWND *phwnd ); [PreserveSig] HRESULT GetWnd(out HWND phwnd); /// /// The ITfContextOwner::GetAttribute method returns the value of a supported attribute. If the attribute is unsupported, /// the pvarValue parameter is set to VT_EMPTY. /// /// Specifies the attribute GUID. /// Receives the attribute value. If the attribute is unsupported, this parameter is set to VT_EMPTY. /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// /// /// Context owners using the default text store of the TSF manager can implement a simplified version of attributes with this /// method. The supported attributes are application or text service dependent. For more information about predefined attributes /// recognized in TSF, see the following topics. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcontextowner-getattribute HRESULT GetAttribute( REFGUID // rguidAttribute, VARIANT *pvarValue ); [PreserveSig] HRESULT GetAttribute(in Guid rguidAttribute, [Out, MarshalAs(UnmanagedType.Struct)] out object pvarValue); } /// /// The ITfContextOwnerCompositionServices interface is implemented by the TSF manager and used by a context owner to /// manipulate compositions created by a text service. /// /// /// /// Normally, an application creates a context and is the context owner. On occasion a text service will create a context. In this /// case, the text service is the context owner. For more information, see Edit Contexts. /// /// Obtain this interface by calling ITfContext::QueryInterface with IID_ITfContextOwnerCompositionServices. /// Examples /// ITfContext /// /// HRESULT hr; ITfContextOwnerCompositionServices *pCompServices; //Get the ITfContextOwnerCompositionServices interface pointer. hr = m_pContext->QueryInterface(IID_ITfContextOwnerCompositionServices, (LPVOID*)&pCompServices); if(SUCCEEDED(hr)) { //Use the interface. //Release the interface. pCompServices->Release(); } /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nn-msctf-itfcontextownercompositionservices [PInvokeData("msctf.h", MSDNShortId = "NN:msctf.ITfContextOwnerCompositionServices")] [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("86462810-593B-4916-9764-19C08E9CE110")] public interface ITfContextOwnerCompositionServices : ITfContextComposition { /// Creates a new composition. /// Contains an edit cookie that identifies the edit context. This is obtained from ITfEditSession::DoEditSession. /// Pointer to an ITfRange object that specifies the text that the composition initially covers. /// /// Pointer to an ITfCompositionSink object that receives composition event notifications. This parameter is optional and can be /// NULL. If supplied, the object is released when the composition is terminated. /// /// /// Pointer to an ITfComposition interface pointer that receives the new composition object. This parameter receives NULL /// if the context owner rejects the composition. /// /// /// /// If the context owner has installed an context owner composition advise sink, the /// ITfContextOwnerCompositionSink::OnStartComposition method is called. If the advise sink rejects the new composition, this /// method returns S_OK but ppComposition is set to NULL. /// /// Any text covered by pCompositionRange receives the GUID_PROP_COMPOSING property. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcontextcomposition-startcomposition HRESULT // StartComposition( TfEditCookie ecWrite, ITfRange *pCompositionRange, ITfCompositionSink *pSink, ITfComposition // **ppComposition ); new ITfComposition StartComposition([In] TfEditCookie ecWrite, [In] ITfRange pCompositionRange, [In, Optional] ITfCompositionSink pSink); /// Creates an enumerator object that contains all compositions in the context. /// Pointer to an IEnumITfCompositionView interface pointer that receives the enumerator object. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcontextcomposition-enumcompositions HRESULT // EnumCompositions( IEnumITfCompositionView **ppEnum ); new IEnumITfCompositionView EnumCompositions(); /// Creates an enumerator object that contains all compositions that intersect a specified range of text. /// Contains an edit cookie that identifies the edit context. This is obtained from ITfEditSession::DoEditSession. /// /// Pointer to an ITfRange object that specifies the range to search. This parameter can be NULL. If this parameter is /// NULL, the enumerator will contain all compositions in the edit context. /// /// Pointer to an IEnumITfCompositionView interface pointer that receives the enumerator object. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcontextcomposition-findcomposition HRESULT // FindComposition( TfEditCookie ecRead, ITfRange *pTestRange, IEnumITfCompositionView **ppEnum ); new IEnumITfCompositionView FindComposition([In] TfEditCookie ecRead, [In, Optional] ITfRange pTestRange); /// Not currently implemented. /// Not used. /// Not used. /// Not used. /// Not used. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcontextcomposition-takeownership HRESULT TakeOwnership( // TfEditCookie ecWrite, ITfCompositionView *pComposition, ITfCompositionSink *pSink, ITfComposition **ppComposition ); new ITfComposition TakeOwnership([In] TfEditCookie ecWrite, [In] ITfCompositionView pComposition, [In] ITfCompositionSink pSink); /// Terminates a composition. /// /// Pointer to a ITfCompositionView interface that represents the composition to terminate. If this value is NULL, all /// compositions in the context are terminated. /// /// /// A text service uses ITfComposition::EndComposition to terminate a composition that it created. /// /// If the context owner implements the text store, the context owner must be able to grant a synchronous write lock before /// calling this method. /// /// This method also does the following: /// /// /// /// For each composition terminated, ITfCompositionSink::OnCompositionTerminated is called for all installed composition advise sinks. /// /// /// /// /// If the context owner installed a context owner composition advise sink, ITfContextOwnerCompositionSink::OnEndComposition is /// called for each terminated composition. /// /// /// /// The GUID_PROP_COMPOSING property will be cleared for the text covered by each terminated composition. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcontextownercompositionservices-terminatecomposition // HRESULT TerminateComposition( ITfCompositionView *pComposition ); void TerminateComposition([In, Optional] ITfCompositionView pComposition); } /// /// The ITfContextOwnerCompositionSink interface is implemented by an application to receive composition-related /// notifications. When the application calls ITfDocumentMgr::CreateContext, the TSF manager queries the object for this interface. /// If the object supports this interface, the advise sink is installed. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nn-msctf-itfcontextownercompositionsink [PInvokeData("msctf.h", MSDNShortId = "NN:msctf.ITfContextOwnerCompositionSink")] [ComImport, Guid("5F20AA40-B57A-4F34-96AB-3576F377CC79"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface ITfContextOwnerCompositionSink { /// Called when a composition is started. /// Pointer to an ITfCompositionView object that represents the new composition. /// /// Pointer to a BOOL value that receives a value that allows or denies the new composition. Receives a nonzero value to /// allow the composition or zero to deny the composition. /// /// /// This method can return one of these values. /// /// /// Value /// Description /// /// /// S_OK /// The method was successful. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcontextownercompositionsink-onstartcomposition HRESULT // OnStartComposition( ITfCompositionView *pComposition, BOOL *pfOk ); [PreserveSig] HRESULT OnStartComposition([In] ITfCompositionView pComposition, [Out, MarshalAs(UnmanagedType.Bool)] out bool pfOk); /// Called when an existing composition is changed. /// Pointer to an ITfCompositionView object that represents the composition updated. /// /// Pointer to an ITfRange object that contains the range of text the composition will cover after the composition is updated. /// /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// To determine what has changed within the composition, compare pRangeNew with the range returned from /// ITfCompositionView::GetRange. The range returned by ITfCompositionView::GetRange is not updated until after /// ITfContextOwnerCompositionSink::OnUpdateComposition returns. /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcontextownercompositionsink-onupdatecomposition HRESULT // OnUpdateComposition( ITfCompositionView *pComposition, ITfRange *pRangeNew ); [PreserveSig] HRESULT OnUpdateComposition([In] ITfCompositionView pComposition, [In] ITfRange pRangeNew); /// Called when a composition is terminated. /// Pointer to an ITfCompositionView object that represents the composition terminated. /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcontextownercompositionsink-onendcomposition HRESULT // OnEndComposition( ITfCompositionView *pComposition ); [PreserveSig] HRESULT OnEndComposition([In] ITfCompositionView pComposition); } /// Obtains a special property that can enumerate multiple properties over multiple ranges. /// The ITfContext instance. /// Contains an array of property identifiers that specify the properties to track. /// Contains the number of property identifiers in the prgProp array. /// Contains an array of application property identifiers that specify the application properties to track. /// Contains the number of application property identifiers in the prgAppProp array. /// Pointer to an ITfReadOnlyProperty interface pointer that receives the tracking property. /// /// /// This method is used to quickly identify ranges with consistent property values for multiple properties. While this method could /// be duplicated using only the ITfContext::GetProperty method, the TSF manager can accomplish this task more quickly. /// /// /// The property obtained by this method is a VT_UNKNOWN type. This property can be used to obtain an IEnumTfPropertyValue /// enumerator by calling the QueryInterface method with IID_IEnumTfPropertyValue. This enumerator contains property values /// specified by prgProp and prgAppProp. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfcontext-trackproperties HRESULT TrackProperties( const GUID // **prgProp, ULONG cProp, const GUID **prgAppProp, ULONG cAppProp, ITfReadOnlyProperty **ppProperty ); public static ITfReadOnlyProperty TrackProperties(this ITfContext ctx, [In, Optional] Guid[] prgProp, [In, Optional] uint cProp, [In, Optional] Guid[] prgAppProp, [In, Optional] uint cAppProp) { unsafe { fixed (Guid* pp = prgProp, pap = prgAppProp) { Guid*[] pprgProp = cProp == 0 ? null : new Guid*[cProp]; for (var i = 0; i < cProp; i++) pprgProp[i] = &pp[i]; Guid*[] pprgAppProp = cAppProp == 0 ? null : new Guid*[cAppProp]; for (var i = 0; i < cAppProp; i++) pprgAppProp[i] = &pap[i]; fixed (Guid** ppp = pprgProp, ppap = pprgAppProp) return ctx.TrackProperties((IntPtr)ppp, cProp, (IntPtr)ppap, cAppProp); } } } } [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false)] internal class NullAllowedAttribute : Attribute { } }