WPF Window size not affected by TabTip keyboard
Asked Answered
N

3

11

I have a WPF application running on a Windows 8.1 tablet. the application is using the following method to show the virtual keyboard:

public static void OpenKeyboard()
{
    ProcessStartInfo startInfo =
        new ProcessStartInfo(@"C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe")
        {
            WindowStyle = ProcessWindowStyle.Hidden
        };
    Process.Start(startInfo);
}

However, the size of the active window that the keyboard is displayed on top of doesn't change accordingly, meaning that if I have a ScrollViewer surrounding all the elements of my window it doesn't respond to the keyboard.
Is there any way to make my windows aware of the keyboard presence?
Update
Tried registering to the SizeChanged event of the window but it's not raised when the keyboard pops up.

Nellienellir answered 27/5, 2015 at 12:27 Comment(1)
Have you ever found a way to make the ScrollViewer respond to TabTip?Chamfer
H
2

Since TabTip.exe is a separate process it doesn't fire any events in your WPF application. Since win 8.1 tabtip does not automatically resize windows anymore. (there have been a lot of complaints about it)

There are a couple of ways you can do this manually. Firstly, Win8 apps have so called "LayoutAware" pages. Something similar can be done in WPF using the VisualStateManager. This is rather complex and might not be the best solution, but I included it nevertheless (VisualStateManager solution here

Another way is to get the tabtip process from the list of active processes and calculate its width and height and use it to manually resize your screens. Tabtip is if I remember correctly about 270 in height. You can also directly resize your screens as soon as the process appears. Something like this;

  public void OpenKeyboard()
         {
             ProcessStartInfo startInfo =
                 new ProcessStartInfo(@"C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe")
                 {
                     WindowStyle = ProcessWindowStyle.Hidden
                 };
             Process.Start(startInfo);

             //this = your window
             this.Height -= 270;

         }

There is another more clean way. It is a bit difficult and I haven't tried it myself yet. It is possible to grab the process and resize it where you want. You might be able to do it with the Windows API call 'findWindow()', but as far as I know that doesn't always work with tabtip, you might have to use P/Invoke. To get you started I found some pretty great sources from which I wont steal credit by copying the code here; How to resize another application's window in C#

Changing another applications size and position using P/invoke (win32)

I hope you find this info useful. I know how you feel and have struggled with tabtip myself more often than id like.

Footnote; isn't it easier to just decrease your max window height and move it to the top of the screen when osk is called and put it back when its killed?

Homotaxis answered 11/12, 2018 at 11:7 Comment(1)
as far as I can see, the VisualStateManager solution is not changing the scroll content. I've created a small demo of the original question. It would be great if you could guide me how to use your solution - correctly.Chamfer
O
1

As far as I know this happens if the window is maximized or not resizable. Mke sure its state is not maximized before opening the keyboard.

Onega answered 25/5, 2016 at 11:23 Comment(0)
A
1

In another answer I provided from my own research on working with tablets, the following S/O link might help you.

Tablet App, Auto Rotation and Taskbar Height Adjustments

I found a variety of things that were not cool, but did come up with some understanding points. Depending on the keyboard, does it actually overlay, or is it part of the anchored taskbar at the bottom of the window with other open tasks. If so, that will inherently change the window available dimensions, almost like a user changing from a lower to higher resolution (or hi/low). This actually changes the view port dimensions for the windows to be displayed. You can hook into

SystemEvents.UserPreferenceChanged and 
SystemEvents.DisplaySettingsChanged 

to detect and trigger whatever resizing considerations you need. There is also code on forcing your tablet to remain in a single orientation. I needed this because our tablet has a barcode scanner on it and it makes sense to always have the tablet with the scanner NOT pointing to the person, so we have it locked in a specific direction while the app is running.

And lastly, how do you KNOW you have entered (or exited) tablet mode. This shows how to hookup with ManagementEventWatcher to detect when registry entry changes interactively such as rotation, or undocking from a station and becoming free to use in tablet mode.

From your feedback, lets have you try this. From my version of TabTip (Surface Pro tablet), in the top-left is the keyboard settings. From that, if you click on it, it will open a dialog that allow for different keyboard styles from full width, abbreviated, split keyboard and even stylus for writing directly. Below that is an option to have your keyboard docked as the taskbar (left button I circled in red) vs floating window on top of others (I believe yours is running). Try setting your keyboard to a DOCKED state, then check the tablet mode and window environment settings getting changed. Worked for me.

enter image description here

Austro answered 11/12, 2018 at 13:29 Comment(5)
Unfortunately, both SystemEvents.UserPreferenceChanged and SystemEvents.DisplaySettingsChanged are not triggered when TabTip is opened. (tested on W10 1803)Chamfer
@Yoav, see revised comment about docking the virtual TabTip keyboardAustro
I've read the revised comment, but this is already the state on my end and the mentioned events aren't triggered. I suspect this is something with W10 V1703 and up. see my tester linkChamfer
@itsho, did you also see the context in the other solution re: "ManagementEventWatcher" that too helped, but will also look at your tester link later.Austro
in my case it's a regular PC with touch screen, so ManagementEventWatcher is less relevant for me. The issue is with TabTip covering parts the application - UNLIKE windows 8 behavior - see this discussionChamfer

© 2022 - 2024 — McMap. All rights reserved.