zoukankan      html  css  js  c++  java
  • 窗口的力量前进

    介绍 在使用了来自代码项目的代码示例和代码片段那么多时间之后,是时候贡献一些东西了。本文展示了在您自己的项目中使用Form类中的两个预编程属性是多么容易。这说明做这个是多么容易。WindowState这。最上层可以使用。 的代码 force forward函数小而简单,调用它时使用bool值强制窗口位于顶部,或者将其重置为正常。如果窗口已最小化到任务栏,则窗口状态将更改为正常状态,因此它将从任务栏弹出。 隐藏,复制Code

    private void ForceForward(bool forceForward)
    {
        if (forceForward)
        {
            // Force the window up from taskbar if needed...
            if (this.WindowState == FormWindowState.Minimized)
                this.WindowState = FormWindowState.Normal;
    
            // Top most windows...
            this.TopMost = true;
        }
    
        // If not force forward, set TopMost back
        // to original state...
        else
            this.TopMost = false;
    }

    序列 本程序使用定时器进行演示。当计时器启动时,延迟被设置为5秒。对于计时器每“滴答”一次,延迟就减少1。当延迟达到0(或低于0)时,它执行ForceForward(true),然后结束序列。 隐藏,收缩,复制Code

    private void btStart_Click(object sender, EventArgs e)
    {
        // Start button set to false!
        btStart.Enabled = false;
    
        // Run once every second (1000ms = 1sec)...
        timer.Enabled = true;
        timer.Interval = 1000;
    
        // Delay is set to 5 seconds...
        delay = 5;
    
        // Show on form in begining of countdown...
        lbCountdown.Text = delay.ToString();
        this.Text = delay.ToString();
    
        // Start the timer...
        timer.Start();
    }
    
    private void timer_Tick(object sender, EventArgs e)
    {
        // Decrease delay...
        delay--;
    
        // Show countdown status...
        lbCountdown.Text = delay.ToString();
        this.Text = delay.ToString();
    
        // When delay has reached zero, ForceForward...
        if (delay <= 0)
        {
            ForceForward(true);
            EndSequence();
        }
    }
    
    private void EndSequence()
    {
        // Stop and disable...
        timer.Stop();
        timer.Enabled = false;
    
        // Reset countdown label...
        lbCountdown.Text = "";
        this.Text = "Force Forward";
    
        // Start button now enabled for next force...
        btStart.Enabled = true;
    
        // Now set back to normal... 
        ForceForward(false);
    }

    当结束序列执行完毕,定时器停止,程序恢复正常;它不再是“最顶层”的窗口。 本文转载于:http://www.diyabc.com/frontweb/news11165.html

  • 相关阅读:
    dynamic不能使用扩展方法
    C# .Net 中字典Dictionary<TKey,TValue>泛型类 学习浅谈
    C# .Net List<T>中Remove()、RemoveAt()、RemoveRange()、RemoveAll()的区别,List<T>删除汇总
    Tomcat配置虚拟目录映射
    JAVA中令人疑惑的字符串
    JAVA控制台版斗地主
    JAVA学习路线
    vue安装(npm和cnpm)
    ThinkPad笔记本无法禁用触摸屏【亲测,有用】
    boostrap弹框之BootstrapDialog
  • 原文地址:https://www.cnblogs.com/Dincat/p/13473319.html
Copyright © 2011-2022 走看看