Window mobile 軟鍵盤IME設定

來源:互聯網
上載者:User

(Input Method Manager,簡稱IMM)

 

using Microsoft.WindowsCE.Forms;

 

InputPanel ip = new InputPanel();
foreach(InputMethod p in ip.InputMethods)
{
     treeView1.Nodes.Add(new TreeNode(p.Name));

}

 

這樣可以得到系統中安裝的所有IME。比如我的是A4IME及本機內建拼音手寫IME等。

 

 

在特定的輸入框中,我們有時只需輸入數字,或者英文,這樣要對IME“拼”“英”“符”等三項進行切換。需要使用到

 

BOOL ImmSetConversionStatus(
  HIMC hIMC,
  DWORD fdwConversion,
  DWORD fdwSentence
);

 

參數一:控制代碼

 

參數二: IMN_SETCONVERSIONMODE

Value Description

IME_CMODE_CHARCODE

Set to 1 if character code input mode; 0 if not.

IME_CMODE_EUDC

Set to 1 if EUDC conversion mode; 0 if not.

IME_CMODE_FULLSHAPE

Set to 1 if full shape mode; 0 if half shape mode.

IME_CMODE_HANJACONVERT

Set to 1 if HANJA convert mode; 0 if not.

IME_CMODE_KATAKANA

Set to 1 if KATAKANA mode; 0 if HIRAGANA mode.

IME_CMODE_NATIVE

Set to 1 if NATIVE mode; 0 if ALPHANUMERIC mode.

IME_CMODE_NOCONVERSION

Set to 1 to prevent processing of conversions by IME; 0 if not.

IME_CMODE_ROMAN

Set to 1 if ROMAN input mode; 0 if not.

IME_CMODE_SOFTKBD

Set to 1 if Soft Keyboard mode; 0 if not.

 

 

參數三: IMN_SETSENTENCEMODE

Value Description

IME_SMODE_AUTOMATIC

The IME carries out conversion processing in automatic mode.

IME_SMODE_NONE

No information for sentence.

IME_SMODE_PHRASEPREDICT

The IME uses phrase information to predict the next character.

IME_SMODE_PLURALCLAUSE

The IME uses plural clause information to carry out conversion processing.

IME_SMODE_SINGLECONVERT

The IME carries out conversion processing in single-character mode.

 

 

C/C++ code
HIMC hImc;
DWORD dwConv, dwSent;
hImc = ImmGetContext(hwndTarget);
ImmGetConversionStatus(hImc, &dwConv, &dwSent);
if (ImmSetConversionStatus(hImc, IME_CMODE_ALPHANUMERIC, dwSent) == 0)
{
    // error
}
ImmReleaseContext(hwndTarget, hImc);

 

 

C# code

 

IntPtr hwndInput = ImmGetContext(this.Handle);
IntPtr dw1 = IntPtr.Zero;
IntPtr dw2 = IntPtr.Zero;
bool isSuccess = ImmGetConversionStatus(hwndInput, ref dw1, ref dw2);
if (isSuccess)
{
     int intTemp = dw1.ToInt32() & IME_CMODE_SOFTKBD;
     if (intTemp > 0)
          dw1 = (IntPtr)(dw1.ToInt32() ^ IME_CMODE_SOFTKBD);
     else
          dw1 = (IntPtr)(dw1.ToInt32() | IME_CMODE_SOFTKBD);
}
isSuccess = ImmSetConversionStatus(hwndInput, dw1, dw2);
ImmReleaseContext(this.Handle, hwndInput);


public const int IME_CMODE_SOFTKBD = 0x80; 

唉!我內流滿面啊!
找了半天在Coredll.DLL中沒有ImmSetConversionStatus
現在在MSDN協助中找到

// Set input mode for name text box to AlphaCurrent.
  InputModeEditor.SetInputMode(textBox1, InputMode.AlphaCurrent);

  // Set input mode for phone number text box to Numeric.
  InputModeEditor.SetInputMode(textBox2, InputMode.Numeric);

  // Set input mode for city text box to AlphaCurrent.
  InputModeEditor.SetInputMode(textBox3, InputMode.AlphaCurrent);

命名空間:Microsoft.WindowsCE.Forms

 

但是經測試發現,只支援設定smartphone的IME,在ppc,wm5,wm6都是無效的。。。

 

 

繼續鬱悶,強人路過請指導一下!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.