渐隐藏的窗口。

原创 2004年06月23日 12:05:00

using System;<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

using System.ComponentModel;

using System.Drawing;

using System.Resources;

using System.Windows.Forms;

using Microsoft.Win32;

using Message = com.Message;

 

namespace TrafficClient

{

     /// <summary>

     /// Summary description for Reminder.

     /// </summary>

     public class Reminder : Form

     {

         private Timer CloseTimer;

         private IContainer components;

         private PictureBox CloseWindow;

         private LinkLabel ShowMainWindow;

 

         private int StartOpacity;

         private Label SMSHead;

         private Label SMSContent;

         private Form MainWindow;

         private LinkLabel ReplyMessage;

         private LinkLabel StopAnimation;

 

         private bool AutoHide;

 

         public Reminder( Message message, Form parent ) : this(message, parent, true) {}

 

         public Reminder( Message message, Form parent, bool autoHide )

         {

              //

              // Required for Windows Form Designer support

              //

              InitializeComponent();

 

              //

              // TODO: Add any constructor code after InitializeComponent call

              //

              this.SMSHead.Text = message.UserPhone + "/n" + message.HappenTime;

              this.SMSContent.Text = message.Content;

 

              this.AutoHide = autoHide;

 

              this.MainWindow = parent;

         }

 

         /// <summary>

         /// Clean up any resources being used.

         /// </summary>

         protected override void Dispose( bool disposing )

         {

              if( disposing )

              {

                   if(components != null)

                   {

                       components.Dispose();

                   }

              }

              base.Dispose( disposing );

         }

 

         #region Windows Form Designer generated code

         /// <summary>

         /// Required method for Designer support - do not modify

         /// the contents of this method with the code editor.

         /// </summary>

         private void InitializeComponent()

         {

              this.components = new Container();

              ResourceManager resources = new ResourceManager(typeof(Reminder));

              this.SMSHead = new Label();

              this.SMSContent = new Label();

              this.ShowMainWindow = new LinkLabel();

              this.CloseTimer = new Timer(this.components);

              this.CloseWindow = new PictureBox();

              this.ReplyMessage = new LinkLabel();

              this.StopAnimation = new LinkLabel();

              this.SuspendLayout();

              //

              // SMSHead

              //

              this.SMSHead.Location = new Point(16, 8);

              this.SMSHead.Name = "SMSHead";

              this.SMSHead.Size = new Size(440, 56);

              this.SMSHead.TabIndex = 0;

              //

              // SMSContent

              //

              this.SMSContent.Font = new Font("STZhongsong", <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />16F, FontStyle.Bold, GraphicsUnit.Point, ((Byte)(134)));

              this.SMSContent.Location = new Point(16, 80);

              this.SMSContent.Name = "SMSContent";

              this.SMSContent.Size = new Size(472, 232);

              this.SMSContent.TabIndex = 1;

              //

              // ShowMainWindow

              //

              this.ShowMainWindow.Location = new Point(440, 320);

              this.ShowMainWindow.Name = "ShowMainWindow";

              this.ShowMainWindow.Size = new Size(56, 16);

              this.ShowMainWindow.TabIndex = 2;

              this.ShowMainWindow.TabStop = true;

              this.ShowMainWindow.Text = "显示界面";

              this.ShowMainWindow.LinkClicked += new LinkLabelLinkClickedEventHandler(this.ShowMainWindow_LinkClicked);

              //

              // CloseTimer

              //

              this.CloseTimer.Interval = 50;

              this.CloseTimer.Tick += new EventHandler(this.CloseTimer_Tick);

              //

              // CloseWindow

              //

              this.CloseWindow.Image = ((Image)(resources.GetObject("CloseWindow.Image")));

              this.CloseWindow.Location = new Point(472, 0);

              this.CloseWindow.Name = "CloseWindow";

              this.CloseWindow.Size = new Size(32, 32);

              this.CloseWindow.TabIndex = 3;

              this.CloseWindow.TabStop = false;

              this.CloseWindow.Click += new EventHandler(this.CloseWindow_Click);

              //

              // ReplyMessage

              //

              this.ReplyMessage.Location = new Point(8, 320);

              this.ReplyMessage.Name = "ReplyMessage";

              this.ReplyMessage.Size = new Size(56, 16);

              this.ReplyMessage.TabIndex = 4;

              this.ReplyMessage.TabStop = true;

              this.ReplyMessage.Text = "回复信息";

              //

              // StopAnimation

              //

              this.StopAnimation.Location = new Point(360, 320);

              this.StopAnimation.Name = "StopAnimation";

              this.StopAnimation.Size = new Size(56, 16);

              this.StopAnimation.TabIndex = 5;

              this.StopAnimation.TabStop = true;

              this.StopAnimation.Text = "停止关闭";

              this.StopAnimation.LinkClicked += new LinkLabelLinkClickedEventHandler(this.StopAnimation_LinkClicked);

              //

              // Reminder

              //

              this.AutoScaleBaseSize = new Size(5, 13);

              this.BackColor = SystemColors.Info;

              this.ClientSize = new Size(502, 342);

              this.ControlBox = false;

              this.Controls.Add(this.StopAnimation);

              this.Controls.Add(this.ReplyMessage);

              this.Controls.Add(this.CloseWindow);

              this.Controls.Add(this.ShowMainWindow);

              this.Controls.Add(this.SMSContent);

              this.Controls.Add(this.SMSHead);

              this.FormBorderStyle = FormBorderStyle.FixedSingle;

              this.Icon = ((Icon)(resources.GetObject("$this.Icon")));

              this.MaximizeBox = false;

              this.MinimizeBox = false;

              this.Name = "Reminder";

              this.ShowInTaskbar = false;

              this.StartPosition = FormStartPosition.CenterScreen;

              this.TopMost = true;

              this.Load += new EventHandler(this.Reminder_Load);

              this.ResumeLayout(false);

 

         }

         #endregion

 

         private void CloseTimer_Tick(object sender, EventArgs e)

         {

              DecreaseOpacity();

         }

 

         private void DecreaseOpacity()

         {

              this.StartOpacity --;

              this.Opacity = (double) this.StartOpacity / 100;

 

              if (this.StartOpacity == 0)

              this.Dispose();

         }

 

         private void Reminder_Load(object sender, EventArgs e)

         {

              if (this.AutoHide)

                   this.CloseTimer.Start();

 

              this.InitStartOpacity();

         }

 

         private void CloseWindow_Click(object sender, EventArgs e)

         {

              this.Dispose();

         }

 

         private void ShowMainWindow_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)

         {

              this.MainWindow.Show();

         }

 

         private void StopAnimation_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)

         {

              this.CloseTimer.Stop();

 

              this.InitStartOpacity();

         }

 

         private void InitStartOpacity()

         {

              this.StartOpacity = Int32.Parse(Registry.LocalMachine.OpenSubKey(@"SOFTWARE/TrafficClient").GetValue("ReminderOpacity", "50").ToString());

 

              this.Opacity = (double) this.StartOpacity / 100;

         }

 

     }

}

 

C#中窗体渐显渐隐

资源设计时,先将窗体的Opacity属性值设置为0% 然后往窗体上放置一个100ms定时器, 其Enable属性设置为true, 然后编写如下代码:   private bool bExitFor...
  • xingyu_soft
  • xingyu_soft
  • 2016年02月22日 09:13
  • 812

C# 半透明渐显窗体

private void timer1_Tick(object sender, EventArgs e) { this.Opacity += 0.1; ...
  • haoduo123456789001
  • haoduo123456789001
  • 2016年05月12日 08:34
  • 509

WPF图片背景框四周渐入和渐出动画

前言:在开发中,我们常常为了让界面更有质感,和更有流畅感,需s
  • loryrichie
  • loryrichie
  • 2014年06月23日 00:10
  • 1408

隐藏CMD窗口

方法: 创建一个vb script脚本,调用batSet ws = CreateObject("Wscript.Shell") ws.run "cmd /c E:\test.bat",vbhide...
  • duanbeibei
  • duanbeibei
  • 2014年12月24日 10:09
  • 1619

createprocess创建进程并隐藏新进程的窗口

方法很简单,在createprocess调用时修改一下STARTUPINFO的参数,使其隐藏即可。下面是代码示例:PROCESS_INFORMATION pi;STARTUPINFO si;     ...
  • highyyy
  • highyyy
  • 2011年01月11日 19:48
  • 5835

Qt实现窗口自动隐藏

将窗口拖到窗口最上方,或最左方,移开鼠标,窗口自动隐藏。 将鼠标移到窗口边界,窗口自动弹出,类音速启动效果 from PyQt4.QtGui import * from PyQt4.Qt...
  • koilin
  • koilin
  • 2012年07月17日 10:52
  • 5373

Qt之窗口靠边隐藏

Qt之窗口靠边隐藏Qt之窗口靠边隐藏 Qt事件介绍 Qt常见事件 窗口靠边所需应用事件 窗口靠边效果图 码农之路 结尾Qt事件介绍 事件(event)是有系统或者Qt本身在不同的时刻发出的,当用户...
  • ly305750665
  • ly305750665
  • 2016年12月08日 22:39
  • 2677

opencv如何隐藏窗口

今天处理视频的时候想将opencv中的窗口隐藏起来,以便进行多线程的处理。     在opencv中可以通过cvGetWindowHandle获取窗口句柄。cvGetWindowHandle的返回值...
  • ahuang1900
  • ahuang1900
  • 2013年12月18日 00:26
  • 2617

如何隐藏启动Tomcat的window的cmd窗口

 分两种情况: 第一种,Tomcat的EXE安装版,在安装的时候,把NT   Service的勾打上就可以了。    第二种,Tomcat的ZIP解压版可以按如下方式修改:     测试系统Windo...
  • vebasan
  • vebasan
  • 2010年03月02日 09:10
  • 6704

隐藏控制台应用程序的窗口

原址:http://www.cnblogs.com/kex1n/archive/2011/04/10/2011254.html 众所周知,控制台应用程序一般都会显示一个控制台窗口(虚拟DOS窗口),...
  • pony12
  • pony12
  • 2016年08月26日 16:38
  • 973
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:渐隐藏的窗口。
举报原因:
原因补充:

(最多只允许输入30个字)