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

  • 相关阅读:
    分页公共方法
    关于锁表查询的部分SQL
    将Excel中的数据绑定到DataGrid控件中
    CMMI相关信息
    图片在DataGrid中的用法
    关于standard Button和html Button之disabled属性的比较
    VS2003中链接数据库方法
    .NET多语言版本系统功能实现
    Read and Write 单一文件
    为继承masterpage的页面设置defaultbutton和defaultfocus
  • 原文地址:https://www.cnblogs.com/Dincat/p/13473319.html
Copyright © 2011-2022 走看看