逆风飞扬  
顺风也好,逆风也罢,都是驾驭风力而已,君子性非异也,善假与物也。逆风飞扬,也能飞得更高,更远!
在smartphone手机上没有PPC上托管的InputPanel组件,所以控制输入法只能通过API函数来实现了。
方法如下:
 public class InputMethod {
        
public const int GW_Child = 5;
        
public const uint SetInputMode = 0x00DE;

        
public const uint Spell = 0;
        
public const uint T9 = 1;
        
public const uint Numbers = 2;
        
public const uint Text = 3;

        [DllImport(
"coredll.dll")]
        
public static extern IntPtr GetFocus();

        [DllImport("coredll.dll")]
           public static extern IntPtr GetWindow(IntPtr hWnd, uint uCmd);

        [DllImport(
"coredll.dll")]
        
public static extern int SendMessage(IntPtr hWnd, uint Message, uint wParam, uint lParam);

        
public static void SetInputMode(Control ctrl, unit mode) {
            ctrl.Capture 
= true
            IntPtr h 
= GetCapture();
            ctrl.Capture 
= false;
            IntPtr handle 
= GetWindow(h, GW_Child);
            
//设置输入法 
            SendMessage(handle, EM_SetInputMode, 0, mode);
        }

    }

    
//在textbox的GotFocus事件中实现: 
    
//private void textBox_GotFocus(object sender, System.EventArgs e) { 
    
//    InputMethod.SetInputMode(this.textBox,InputMethod.Numbers); 
    
//
posted on 2007-06-05 15:00  逆风飞扬  阅读(668)  评论(0编辑  收藏  举报