線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:9199
推到 Plurk!
推到 Facebook!

在 Vista 底下, 如何以程式切換輸入法 ?

答題得分者是:william
boson
中階會員


發表:74
回覆:155
積分:85
註冊:2004-07-31

發送簡訊給我
#1 引用回覆 回覆 發表時間:2007-05-17 08:54:53 IP:218.162.xxx.xxx 訂閱
在 XP 或 Win2003 底下, 我們可以指定元件的 ImeName 來指定這個元件的中文輸入法,
也可以呼叫 IMM 單元裏面的函數進行切換輸入法

但在 Vista 底下, 這些方法全部失效了

有誰知道 Vista 底下該如何以程式切換輸入法嗎 ?
(例如, 讓 User 一進入某個 Memo 元件即自動切換到注音輸入法)

boson
中階會員


發表:74
回覆:155
積分:85
註冊:2004-07-31

發送簡訊給我
#2 引用回覆 回覆 發表時間:2007-05-18 20:43:38 IP:220.134.xxx.xxx 訂閱
找到了一點線索, 可惜不是 for Delphi 的, 而是 C# 的解法 :
http://www.microsoft.com/taiwan/msdn/columns/huang_jhong_cheng/vista.htm

有沒有人能幫忙改寫成 Delphi ?
編輯記錄
boson 重新編輯於 2007-05-18 20:44:29, 註解 無‧
暗黑破壞神
版主


發表:9
回覆:2301
積分:1627
註冊:2004-10-04

發送簡訊給我
#3 引用回覆 回覆 發表時間:2007-05-25 22:32:08 IP:218.170.xxx.xxx 未訂閱
我沒有 Vista 啦。。。。被你騙過來看這篇。。。。^______^
william
版主


發表:66
回覆:2535
積分:3048
註冊:2002-07-11

發送簡訊給我
#4 引用回覆 回覆 發表時間:2007-05-27 10:56:06 IP:218.190.xxx.xxx 未訂閱
被騙了 

從 MSDN 上翻譯過來, 希望有幫助啦.

type
PF_LANGUAGEPROFILE = ^TF_LANGUAGEPROFILE;
TF_LANGUAGEPROFILE = packed record
clsid: TGUID;
langid: smallint;
catid: TGUID;
fActive: WordBool;
guidProfile: TGUID;
end;

IEnumGUID = interface
['{0002E000-0000-0000-C000-000000000046}']
function Next(celt: Cardinal; out rgelt: TGUID; out pcFetched: Cardinal): HRESULT; stdcall;
function Skip(celt: Cardinal): HRESULT; stdcall;
function Reset: HRESULT; stdcall;
function Clone(out ppEnum: IEnumGUID): HRESULT; stdcall;
end;

IEnumTfLanguageProfiles = interface
['{3D61BF11-AC5F-42C8-A4CB-931BCC28C744}']
function Clone(out ppEnum: IEnumTfLanguageProfiles): HRESULT; stdcall;
function Next(ulCount: Cardinal; const pProfile: PF_LANGUAGEPROFILE; out pcFetch: Cardinal): HRESULT; stdcall;
function Reset: HRESULT; stdcall;
function Skip(ulCount: Cardinal): HRESULT; stdcall;
end;

ITfInputProcessorProfiles = interface
['{1F02B6C5-7842-4EE6-8A0B-9A24183A95CA}']
function Register(const clsid: TGUID): HRESULT; stdcall;
function Unregister(const clsid: TGUID): HRESULT; stdcall;
function AddLanguageProfile(const clsid: TGUID; langid: smallint; const guidProfile: TGUID; const pchDesc: WideString; cchDesc: Cardinal; const pchIconFile: WideString; cchFile, uIconIndex: Cardinal): HRESULT; stdcall;
function RemoveLanguageProfile(const clsid: TGUID; langid: smallint; out guidProfile: TGUID): HRESULT; stdcall;
function EnumInputProcessorInfo(out ppEnum: IEnumGUID): HRESULT; stdcall;
function GetDefaultLanguageProfile(langid: smallint; const catid: TGUID; out clsid: TGUID; out guidProfile: TGUID): HRESULT; stdcall;
function SetDefaultLanguageProfile(langid: smallint; const clsid: TGUID; const guidProfile: TGUID): HRESULT; stdcall;
function ActivateLanguageProfile(const clsid: TGUID; langid: smallint; const guidProfiles: TGUID): HRESULT; stdcall;
function GetActiveLanguageProfile(const clsid: TGUID; out langid: smallint; out guidProfile: TGUID): HRESULT; stdcall;
function GetLanguageProfileDescription(const clsid: TGUID; langid: smallint; const guidProfile: TGUID; out pbstrProfile: WideString): HRESULT; stdcall;
function GetCurrentLanguage(out langid: smallint): HRESULT; stdcall;
function ChangeCurrentLanguage(langid: smallint): HRESULT; stdcall;
function GetLanguageList(out ppLangId: pointer; out ulCount: Cardinal): HRESULT; stdcall;
function EnumLanguageProfiles(langid: smallint; out ppEnum: IEnumTfLanguageProfiles): HRESULT; stdcall;
function EnableLanguageProfile(const clsid: TGUID; langid: smallint; const guidProfile: TGUID; fEnable: WordBool): HRESULT; stdcall;
function IsEnabledLanguageProfile(const clsid: TGUID; langid: smallint; const guidProfile: TGUID; out fEnabled: WordBool): HRESULT; stdcall;
function EnableLanguageProfileByDefault(const clsid: TGUID; langid: smallint; const guidProfile: TGUID; fEnabled: WordBool): HRESULT; stdcall;
function SubstituteKeyboardLayout(const clsid: TGUID; langid: smallint; const guidProfile: TGUID; hKL: pointer): HRESULT; stdcall;
end;

function TF_CreateInputProcessorProfiles(out profiles: ITfInputProcessorProfiles): HRESULT; stdcall; external 'msctf.dll';
編輯記錄
william 重新編輯於 2007-05-27 10:58:11, 註解 無‧
william 重新編輯於 2007-05-27 11:00:08, 註解 無‧
a0
一般會員


發表:11
回覆:29
積分:18
註冊:2003-09-12

發送簡訊給我
#5 引用回覆 回覆 發表時間:2008-03-12 16:53:04 IP:218.161.xxx.xxx 訂閱
感謝 william大的翻譯
IEnumTfLanguageProfiles = interface
['{3D61BF11-AC5F-42C8-A4CB-931BCC28C744}']
function Next(ulCount: Cardinal; const pProfile: PF_LANGUAGEPROFILE; out pcFetch: Cardinal): HRESULT; stdcall;
MSDN 上寫說
HRESULT Next(    ULONG ulCount<!---->,
  TF_LANGUAGEPROFILE* pProfile<!---->,
  ULONG* pcFetch<!----> );

Parameters

ulCount
[in] Specifies the number of elements to obtain.
pProfile
[out] Pointer to an array of TF_LANGUAGEPROFILE structures that receives the requested data. This array must be at least ulCount elements in size.
pcFetch
[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.


NEXT 這樣宣告好像有點奇怪 我在調用 Next 一直無法成功~
看C 宣告語法
Next(int count, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)]
TF_LANGUAGEPROFILE[] profiles, out int fetched);
翻成Delphi不知道要如何宣告








編輯記錄
a0 重新編輯於 2008-03-12 16:55:53, 註解 無‧
a0 重新編輯於 2008-03-12 17:05:02, 註解 無‧
系統時間:2024-04-20 4:48:04
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!