zoukankan      html  css  js  c++  java
  • (软输入面板)重叠控件

    简介

    pc_capture1.JPG pc_capture2.JPG pc_capture3.JPG pc_capture4.JPG

    这篇文章给出了一个简单但很有效的解释,解决问题时,您的控件是不可见的,当你打开 inputpanel 你可以看到在所有的控件的截图是基于适应 inputpanel 和可用空间。

    使用代码

    添加到项目中的类。 这是一个 静态 类,所以它可以调用任何形式。 为了让这项工作,你需要添加一个 inputpanel 控制每个窗体。 如果您使用的是tabpages,那么你通过只在当前标签页。 例如:

    OverLappingInputPanel.Inputpanel(tabControl1.TabPages
    [tabControl1.SelectedIndex].Controls, inputPanel1.Enabled,
    inputPanel1.VisibleDesktop.Height);
    代码
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Windows.Forms;

    namespace MFA_Common
    {
    public static class OverLappingInputPanel
    {
    private static int oldrest = 0;
    private static int oldheight = 0;
    private static int oldtop = 0;
    private static Control isFocused = null;

    /// <summary>
    /// Brings the control that has focus on top of the inputpanel
    /// </summary>
    /// <param name=""controls""></param>
    /// <param name=""SIDCollaps""></param>
    public static void Inputpanel(Control.ControlCollection controls,
    Boolean SIDExpended,
    int Visualdesktopheight)
    {
    try
    {
    if (controls != null)
    {
    if (SIDExpended == true)
    {
    //Loop through the controls to determinate which has focus
    //this can be avoided if the gotfocus event is fired
    //for each control that is beneath the inputpanel if expanded

    foreach (Control ctrl in controls)
    {
    if (ctrl.Focused)
    {
    isFocused
    = ctrl;
    // if this is not the case calculate the needed space
    int rest = Visualdesktopheight - (
    ctrl.Top
    + ctrl.Height);
    if (rest < 0)
    {
    //move each control up with the calculated space
    foreach (Control ctrl2 in controls)
    {
    ctrl2.Top
    = ctrl2.Top + rest;
    }
    oldrest
    = rest;

    }
    if (ctrl.Height > Visualdesktopheight)
    {
    oldtop
    = ctrl.Top;
    oldheight
    = ctrl.Height;
    ctrl.Height
    = Visualdesktopheight;
    ctrl.Top
    = 0;
    }
    }
    }

    //escape the current function if the selected control is
    //not under the inputpanel
    return;
    }
    else
    {
    //when the inputpanel is hidden, recalculate the top position
    //for each control.
    //the old value has to be reversed *-1 to inverse the changes
    //if the control was bigger than the available screen, then
    //give it back its original value
    if (oldheight != 0)
    {
    isFocused.Top
    = oldtop;
    isFocused.Height
    = oldheight;
    oldheight
    = 0;
    }
    foreach (Control ctrl2 in controls)
    {
    ctrl2.Top
    = ctrl2.Top + (-1 * oldrest);
    }
    oldrest
    = 0;
    }
    }
    }

    catch
    {
    //the ObjectDisposedException is trapped here. This occurs when the user
    //doesn't closes the sip before moving to an other screen
    //if an inputpanel is closed on an other form,
    //then the object that is stored is dispose
    //if this is the case, catch the exception and set the object to null;
    oldrest = 0;
    controls
    = null;
    }
    }
    }
    }
  • 相关阅读:
    Java字符集
    ==和equals区别
    web.xml中load-on-startup标签的含义
    使用solrJ管理索引——(十四)
    Solr管理索引库——(十三)
    [置顶] 关于redhat系统yum源的配置1
    设置Oracle用IP远程连接和客户端访问
    jqueryUI中datepicker的使用,解决与asp.net中的UpdatePanel联合使用时的失效问题
    [置顶] 关于redhat系统yum源的配置2
    浅析innodb_support_xa与innodb_flush_log_at_trx_commit
  • 原文地址:https://www.cnblogs.com/Wolves/p/1893622.html
Copyright © 2011-2022 走看看