参考这个帖子中我的回答:
如果移动没有标题栏的窗口?
http://expert.csdn.net/Expert/topic/1453/1453972.xml?temp=.2607233
如果移动没有标题栏的窗口?
http://expert.csdn.net/Expert/topic/1453/1453972.xml?temp=.2607233
解决方案 »
- 关于socket异步的一个怪异问题,遍历socket列表发送消息时必须sleep
- 简单的字符分离
- socket编程 对消息进行校验
- 大家帮助我好急啊...........
- 如何解决xml读取的问题?
- winform程序Icollection没有addrange的定义,怎么办?大哥大姐帮帮忙
- 一些没有CLOSE和DISPOSE的对像或一些自定义的类使用后如何释放内存?
- 请教自动登陆网页的winform程序,高分!
- 每一次使用vss(不知怎样建srcsafe.ini),在线等
- 关于异步套接字的BeginReceive方法的问题?
- 在菜单中打开MDI窗口,但是每一次点击,就出现一个新窗口,如何只出现一个?
- CrystalReport问题
如果你停掉Form2的时间,就达到你要的效果了
Form2 form = new Form2();
form.HeightMax = 120;//窗体滚动的高度
//form.WidthMax = 148;//窗体滚动的宽度
form.WidthMax = 248;//窗体滚动的宽度
form.ScrollShow();Form2.cs
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;namespace Msn
{
/// <summary>
/// Form2 的摘要说明。
/// </summary>
public class Form2 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.Timer timer2;
private System.Windows.Forms.Timer timer3;
private System.ComponentModel.IContainer components; public Form2()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.label1 = new System.Windows.Forms.Label();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.timer2 = new System.Windows.Forms.Timer(this.components);
this.timer3 = new System.Windows.Forms.Timer(this.components);
this.SuspendLayout();
//
// label1
//
this.label1.Font = new System.Drawing.Font("华文行楷", 26.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label1.Location = new System.Drawing.Point(8, 8);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(136, 112);
this.label1.TabIndex = 0;
this.label1.Text = "刘建海来了!!";
//
// timer1
//
this.timer1.Interval = 10;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// timer2
//
this.timer2.Interval = 10;
this.timer2.Tick += new System.EventHandler(this.timer2_Tick);
//
// timer3
//
this.timer3.Interval = 10;
this.timer3.Tick += new System.EventHandler(this.timer3_Tick);
//
// Form2
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackColor = System.Drawing.SystemColors.Info;
this.ClientSize = new System.Drawing.Size(152, 128);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.label1});
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "Form2";
this.ShowInTaskbar = false;
this.Text = "Form2";
this.TopMost = true;
this.Load += new System.EventHandler(this.Form2_Load);
this.ResumeLayout(false); }
#endregion
private int heightMax, widthMax;
public int HeightMax
{
set
{
heightMax = value;
}
get
{
return heightMax;
}
} public int WidthMax
{
set
{
widthMax = value;
}
get
{
return widthMax;
}
}
//添加一个ScrollShow的公共方法: public void ScrollShow()
{
this.Width = widthMax;
this.Height = 0;
this.Show();
this.timer1.Enabled = true;
} //添加一个StayTime属性设置窗体停留时间(默认为5秒): public int StayTime = 5000; //添加ScrollUp和ScrollDown方法来编写窗体如何滚出和滚入: private void ScrollUp()
{
if(Height < heightMax)
{
this.Height += 3;
this.Location = new Point(this.Location.X, this.Location.Y - 3);
}
else
{
this.timer1.Enabled = false;
this.timer2.Enabled = true;
}
} private void ScrollDown()
{
if(Height > 3)
{
this.Height -= 3;
this.Location = new Point(this.Location.X, this.Location.Y + 3);
}
else
{
this.timer3.Enabled = false;
this.Close();
}
} private void timer1_Tick(object sender, System.EventArgs e)
{
ScrollUp(); } private void timer2_Tick(object sender, System.EventArgs e)
{
timer2.Enabled = false;
timer3.Enabled = true; } private void timer3_Tick(object sender, System.EventArgs e)
{
ScrollDown(); } private void Form2_Load(object sender, System.EventArgs e)
{
Screen[] screens = Screen.AllScreens;
Screen screen = screens[0];//获取屏幕变量
this.Location = new Point(screen.WorkingArea.Width - widthMax - 20, screen.WorkingArea.Height - 34);//WorkingArea为Windows桌面的工作区
this.timer2.Interval = StayTime; }
}
}