/// <summary> /// Either create and show, or else re-attach to (if it's already up) the virtual keyboard. /// To be called from the desired target-Window that wants to use it. /// </summary> /// <param name="targetWindow">The Window that wants to be the owner of the virtual-keyboard Window and the target of it's output</param> public static void ShowOrAttachTo(IVirtualKeyboardInjectable targetWindow) { try { _desiredTargetWindow = targetWindow; // Evidently, for modal Windows I can't share user-focus with another Window unless I first close and then recreate it. // A shame. Seems like a waste of time. But I don't know of a work-around to it (yet). if (IsUp) { Console.WriteLine("VirtualKeyboard: re-attaching to a different Window."); VirtualKeyboard.The.Closed += new EventHandler(OnTheKeyboardClosed); VirtualKeyboard.The.Close(); targetWindow.TheVirtualKeyboard = null; } else { VirtualKeyboard virtualKeyboard = ShowIt(targetWindow); targetWindow.TheVirtualKeyboard = virtualKeyboard; } } catch (Exception x) { Console.WriteLine("in VirtualKeyboard.ShowOrAttachTo: " + x.Message); IInterlocution inter = Application.Current as IInterlocution; if (inter != null) { inter.NotifyUserOfError("Well, now this is embarrassing.", "in VirtualKeyboard.ShowOrAttachTo.", x); } } }
public Form1() { _myInterlocutionFacility = JhMessageBox.GetNewInstance("DesignForge", "DemoApp-WindowsForms"); InitializeComponent(); }