0

我想在顯示虛擬鍵盤時點擊文本框。任何想法如何實現虛擬鍵盤到我的應用程序? 此代碼根本沒有任何作用。WinCE ARM輸入虛擬鍵盤

private void textBox1_GotFocus(object sender, EventArgs e) 
    { 
     inputPanel1.Enabled = true; 
    } 

    private void textBox1_LostFocus(object sender, EventArgs e) 
    { 
     inputPanel1.Enabled = false; 
    } 
+0

'Enabled'只在控件響應事件時切換。也許你想要「可見」屬性? – jnovacho

+0

這些實際事件處理程序是否附加到事件,或者您是否僅粘貼了代碼(http://msdn.microsoft.com/zh-cn/library/microsoft.windowsce.forms.inputpanel.aspx)? – GSerg

+0

我只是粘貼代碼,但現在我將這些代碼附加到事件中,但它只顯示一秒鐘而不是關閉 – franzp

回答

1

LostFocus處理程序刪除幫助。我不得不改變鍵盤的位置。這是做非現有財產的唯一方法:// ..也許它對某人有用。

[DllImport("coredll.dll", SetLastError = true)] 
    [return: MarshalAs(UnmanagedType.Bool)] 
    public static extern bool SipGetInfo(
     ref SIPINFO sipInfo); 

    [DllImport("coredll.dll", SetLastError = true)] 
    [return: MarshalAs(UnmanagedType.Bool)] 
    public static extern bool SipSetInfo(
     ref SIPINFO sipInfo); 
    [StructLayout(LayoutKind.Sequential)] 

    public struct SIPINFO 
    { 
     public uint cbSize; 
     public uint fdwFlags; 
     public RECT rcVisibleDesktop; 
     public RECT rcSipRect; 
     public uint dwImDataSize; 
     public IntPtr pvImData; 
    } 

    [StructLayout(LayoutKind.Sequential)] 
    public struct RECT 
    { 
     public int left; 
     public int top; 
     public int right; 
     public int bottom; 
    } 

    private void ShowInputPanel(Control control) 
    { 
     InputPanel.SIPINFO sipInfo; 
     var x = 100; 
     var y = control.PointToScreen(new Point(110, 150)).Y;   //control.Height 

     this.inputPanel1.Enabled = true; 

     sipInfo = new InputPanel.SIPINFO(); 
     sipInfo.cbSize = (uint)Marshal.SizeOf(sipInfo); 
     if (InputPanel.SipGetInfo(ref sipInfo)) 
     { 
      sipInfo.rcSipRect.left = x; 
      sipInfo.rcSipRect.top = y; 

      InputPanel.SipSetInfo(ref sipInfo); 
     } 
    } 

    private void textBox1_GotFocus(object sender, EventArgs e) 
    { 
     this.ShowInputPanel(this.textBox1);   
    }