Window mobile 软键盘输入法设置

(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));

}

 

这样可以得到系统中安装的所有输入法。比如我的是A4输入法及本机自带拼音手写输入法等。

 输入法列表

 

在特定的输入框中,我们有时只需输入数字,或者英文,这样要对输入法“拼”“英”“符”等三项进行切换。需要使用到

 

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的输入法,在ppc,wm5,wm6都是无效的。。。

 


 

继续郁闷,强人路过请指导一下!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值