Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
860 views
in Technique[技术] by (71.8m points)

c# - After killing the process for TabletKeyboard(TabTip.exe) application doesn't bring back to its original size in wpf

I have a wpf application which runs on the windows 8 tablet . And in order to bring the keyboard for typing when the focus is on any TextBox.

I am invoking the process TabTip.exe to show the keyboard, and when the keyboard is shown my application shrinks. And after all manipulation, there is a save button. When I click on the save button, the keyboard should disappear and my application should come back to its original size.

I am killing the process TabTip.exe to close the keyboard, but the application will not get re-sized to its original size .

I tried:

if (process.ProcessName == "TabTip")
{
    Application.Current.MainWindow.VerticalAlignment = VerticalAlignment.Stretch;
    process.Kill();
    Application.Current.MainWindow.Height = SystemParameters.WorkArea.Height;
    Application.Current.MainWindow.Width = SystemParameters.WorkArea.Width;
    Application.Current.MainWindow.WindowState = WindowState.Normal;
    Application.Current.MainWindow.WindowState = WindowState.Maximized;
    break;
} 

Does anybody knows to restore the application to its original size after killing the TabTip.exe?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The Windows 8 keyboard has a number of rendering problems. These can be mitigated by starting the keyboard in its smaller mode (equivalent to hitting the minimize button). It plays much better with WPF then, actually minimizing and expanding when the process is launched and closed.

This requires launching the process in this mode, and closing it in a nicer way than you are doing right now

Include these libraries:

using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows.Interop;

And define this external functions:

[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("user32.dll", SetLastError = true)]
public static extern bool PostMessage(int hWnd, uint Msg, int wParam, int lParam);

[DllImport("user32.dll")]
public static extern IntPtr FindWindow(String sClassName, String sAppName);

Open the keyboard with:

public static void openKeyboard()
    {
        ProcessStartInfo startInfo = new ProcessStartInfo(@"C:Program FilesCommon FilesMicrosoft SharedinkTabTip.exe");
        startInfo.WindowStyle = ProcessWindowStyle.Hidden;
        myProcess = Process.Start(startInfo);
    }

and close it with:

public static void closeKeyboard()
    {
        uint WM_SYSCOMMAND = 274;
        uint SC_CLOSE = 61536;
        IntPtr KeyboardWnd = FindWindow("IPTip_Main_Window", null);
        PostMessage(KeyboardWnd.ToInt32(), WM_SYSCOMMAND, (int)SC_CLOSE, 0);
    }

This will give you the best behaved windows 8 on screen keyboard you can get. With any luck it will fix your rendering issues.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...