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;
    }
    }
    }
    }
  • 相关阅读:
    201871010125 王玉江 实验三 软件工程结对项目
    201871010125-王玉江 实验二 个人项目—《背包问题》项目报告
    201871010125 王玉江 实验一 软件工程准备—软件工程初步认识
    201871010125-王玉江《面向对象程序设计(java)》第十五周学习总结
    201871010125 王玉江《面向对象程序设计(java)》第十三周学习总结
    201871010125 王玉江 《面向对象程序设计(Java)》第八周实验总结
    201871010125 王玉江 《面向对象程序设计(java)》 第四周学习总结
    201871010125王玉江第二十周总结
    第一次作业
    【 D3.js 入门系列 — 0 】 简介和安装
  • 原文地址:https://www.cnblogs.com/Wolves/p/1893622.html
Copyright © 2011-2022 走看看