2011-09-03 63 views
2

我有一個應用程序,實質上是一個嚮導,通過一些對話框。其中一種形式只有一個按鈕,可以調出常見的「拍照」對話框。如何隱藏Windows Mobile 6.5中的小鍵盤彈出窗口? (c#)

在圖片功能被解除後,小鍵盤圖標顯示出來(不方便地覆蓋了我的一個嚮導按鈕)。

我試圖通過調用設置覆蓋窗口氟利昂:

nextButton.BringToFront(); 

但是這並沒有影響。我需要以某種方式禁用小鍵盤圖標,不知道該怎麼做。

注意 - 這不是軟鍵盤 - 但是用戶點擊的圖像會帶來這種情況。

注意 - 此表單上沒有文本控件 - 只有4個按鈕 - 一個啓動CameraCaptureDialog,另外一些控制用戶進入「下一個」和「上一個」屏幕。

編輯

既然兩個人都非常有信心自己的代碼將工作,看網上的引用我想他們可能是對的,我想我會詳細說明問題,因爲既不建議解決這個問題。

在我選擇「拍照」/ CameraCaptureDialog中的菜單上的取消或OK按鈕後,鍵盤項似乎是剩餘的剩餘部分。

關於退出對話框,我似乎有中間/鍵盤菜單項遺留下來,我似乎沒有什麼能夠做到這一點。

這裏是什麼樣子的仿真器(上仿真器同樣會發生) enter image description here

注 - 調用以下所有對鍵盤圖標沒有影響啄隱藏按鈕:

// nextButton is the Button on the control hidden by the keyboard icon thingy 
nextButton.Focus(); 
nextButton.BringToFront(); 
nextButton.Invalidate(); 
nextButton.Refresh(); 
nextButton.Show(); 

回答

5

我還在尋找隱藏小鍵盤圖標(SIP圖標)的解決方案,我通過使用FindWindowWMoveWindowSetWindowPos功能coredll.dlluser32.dll

聲明函數,我們感興趣的是:

[DllImport("coredll.dll", EntryPoint = "FindWindowW", SetLastError = true)] 
    private static extern IntPtr FindWindow(string lpClassName, string lpWindowName); 

    [DllImport("coredll.dll", SetLastError = true)] 
    [return: MarshalAs(UnmanagedType.Bool)] 
    private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags); 

然後找到手感鍵盤圖標,並調用SetWindowPos來隱藏它:

IntPtr hWnd = FindWindow(Nothing, "MS_SIPBUTTON"); 
SetWindowPos(hWnd, 1, 0, 0, 0, 0, &H80); 

相關鏈接:

  1. P/Invoke - coredll.dll
  2. Disable keyboard icon in Windows Mobile using VB.net
  3. Manage SIP - 跳過這個帖子上的底部,並查找用戶名馬克

編輯 評論

我只好稍微修改這個編譯。

const int SWP_HIDE = 0x0080; 
    IntPtr hWnd = FindWindow(null, "MS_SIPBUTTON"); 
    SetWindowPos(hWnd, IntPtr.Zero, 0, 0, 0, 0, SWP_HIDE); 
+0

是,工作都是圍繞我這裏張貼大約是隱藏圖標而不是實際的鍵盤和MS_SIPBUTTON指按鈕圖標 – Waqas

+0

OK,我知道了,謝謝。儘管在調用引用的代碼中我得到了異常。這就是爲什麼它不起作用,我想象。不知道爲什麼會發生。我需要做什麼特別的事情才能讓這些工作? – Tim

+0

user32名稱必須更改爲coredll,我認爲它的工作原理。 – Tim

1
[DllImport("coredll.dll", EntryPoint = "SipShowIM")] 
public static extern bool SipShowIMP(int code); 

SipShowIMP(1); //Show the keyboard 

SipShowIMP(0); //Hide the keyboard 

應該這樣做:-)

1

這個答案是從下面的文章http://beemobile4.net/support/technical-articles/windows-mobile-programming-tricks-on-net-compact-framework-12(我只加了using語句)拍攝。我在Windows Mobile 6.1 Classic,.NET CF 3.5上。

using System; 
using System.Runtime.InteropServices; 

[DllImport("coredll.dll", SetLastError = true)] 
private static extern IntPtr FindWindow(string caption, string className); 

[DllImport("coredll.dll", SetLastError = true)] 
private static extern bool ShowWindow(IntPtr hwnd, int state); 

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

private const int SW_HIDE = 0; 
private const int SW_SHOW = 1; 
private const int GW_CHILD = 5; 

///   
/// Shows the SIP (Software Input Panel) button.   
/// 
static public void ShowHideSIP(int nShowOrHide) 
{ 
    IntPtr hSipWindow = FindWindow("MS_SIPBUTTON", "MS_SIPBUTTON"); 
    if (hSipWindow != IntPtr.Zero) 
    { 
     IntPtr hSipButton = GetWindow(hSipWindow, GW_CHILD); 
     if (hSipButton != IntPtr.Zero) 
     { 
      bool res = ShowWindow(hSipButton, nShowOrHide); 
     } 
    } 
} 
相關問題