void inputPanel_EnabledChanged(object sender, System.EventArgs e) { Size changeFormSizeTo; if (Bounds != inputPanel.VisibleDesktop) { if (inputPanel.Enabled || previousSize == null) { // remember the form's size before the soft keyboard was opened previousSize = Size; changeFormSizeTo = inputPanel.VisibleDesktop.Size; } else { // use the size from before the soft keyboard was opened - the VisibleDesktop ignores // the menu bar size changeFormSizeTo = previousSize; } // Set the new size. The .Net way of changing the bounds does not work in this case, // so lets do it via win32 functions NativeWindowCommon.SetWindowPos(Handle, IntPtr.Zero, 0, 0, changeFormSizeTo.Width, changeFormSizeTo.Height, NativeWindowCommon.SWP_NOMOVE | NativeWindowCommon.SWP_NOZORDER); } }
/// <summary> /// Invalidates the non client area of the rich text box control. /// </summary> private void InvalidateNC() { NativeWindowCommon.SetWindowPos(this.Handle, IntPtr.Zero, 0, 0, 0, 0, NativeWindowCommon.SWP_NOMOVE | NativeWindowCommon.SWP_NOSIZE | NativeWindowCommon.SWP_NOZORDER | NativeWindowCommon.SWP_NOACTIVATE | NativeWindowCommon.SWP_DRAWFRAME); }
/// <summary> Catch the enable/disable of the soft keyboard. When the keyboard state changes, /// resize the active form and scroll to the control in focus /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void inputPanel_EnabledChanged(object sender, EventArgs e) { // Get the active form ClientManager cm = ClientManager.Instance; tasks.Task task = cm.getLastFocusedTask(); if (task == null) { return; } MgForm mgForm = (MgForm)cm.getLastFocusedTask().getForm(); if (mgForm == null) { return; } mgForm = (MgForm)mgForm.getTopMostForm(); Form form = GuiCommandQueue.getInstance().mgFormToForm(mgForm); // If form size changed if (form != null && form.Bounds != _inputPanel.VisibleDesktop) { Size changeFormSizeTo; if (_inputPanel.Enabled || _previousSize == null) { // remember the form's size before the soft keyboard was opened _previousSize = form.Size; changeFormSizeTo = _inputPanel.VisibleDesktop.Size; } else { // use the size from before the soft keyboard was opened - the VisibleDesktop ignores // the menu bar size changeFormSizeTo = _previousSize; } // Set the new size. The .Net way of changing the bounds does not work in this case, // so lets do it via win32 functions NativeWindowCommon.SetWindowPos(form.Handle, IntPtr.Zero, 0, 0, changeFormSizeTo.Width, changeFormSizeTo.Height, NativeWindowCommon.SWP_NOMOVE | NativeWindowCommon.SWP_NOZORDER); // Find the control in focus and scroll to it MapData mapData = ((TagData)form.Tag).LastFocusedMapData; GuiMgControl guiMgcontrol = mapData.getControl(); if (guiMgcontrol == null) { return; } object o = ControlsMap.getInstance().object2Widget(guiMgcontrol, mapData.getIdx()); Control control = null; LogicalControl logicalControl = null; if (o is LogicalControl) { logicalControl = (LogicalControl)o; control = logicalControl.getEditorControl(); } else { control = (Control)o; } GuiUtils.scrollToControl(control, logicalControl); } }