QQ停靠特效

主要是 " QQ窗体停靠 " 的效果

form1代码:

using  System;
using  System.Drawing;
using  System.Collections;
using  System.ComponentModel;
using  System.Windows.Forms;
using  System.Data;
using  System.Runtime.InteropServices;

namespace  QQ
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>

public class Form1 : System.Windows.Forms.Form
{
   
private System.ComponentModel.IContainer components;

   
public Form1()
   
{
    
//
    
// Windows 窗体设计器支持所必需的
    
//
    InitializeComponent();

    
//
    
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
    
//
   }


   
/// <summary>
   
/// 清理所有正在使用的资源。
   
/// </summary>

   protected override void Dispose( bool disposing )
   
{
    
if( disposing )
    
{
     
if (components != null
     
{
      components.Dispose();
     }

    }

    
base.Dispose( disposing );
   }


   
Windows 窗体设计器生成的代码

   
/// <summary>
   
/// 应用程序的主入口点。
   
/// </summary>

   [STAThread]
   
static void Main() 
   
{
    Application.Run(
new Form2());
   }

   
int dx;
   
int dy;
   
private System.Windows.Forms.NotifyIcon notifyIcon1;
   
private System.Windows.Forms.PictureBox pictureBox1;
   
private System.Windows.Forms.PictureBox pictureBox2;
   
private System.Windows.Forms.ContextMenu contextMenu1;
   
private System.Windows.Forms.MenuItem menuItem1;
   
private System.Windows.Forms.MenuItem menuItem2;
   
int shubiao;
   
private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
   
{
    
if(e.Button ==MouseButtons.Left)
    
{
     dx
=e.X ;dy=e.Y;
    }


   }


    
private void Form1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
   
{
    
if(e.Button ==MouseButtons.Left&&this.Size .Height ==577)
    
{
     
this.Left =this.Left +(e.X -dx);
   
      
this.Top =this.Top +(e.Y -dy);

     Application.DoEvents ();
/*节省运行资源*/
    }


   
   }


private void Form1_MouseEnter(object sender, System.EventArgs e)
       
{
this.ClientSize = new System.Drawing.Size(196,577);
this.shubiao =1;
  
         }


private void Form1_MouseLeave(object sender, System.EventArgs e)
{
    
this.shubiao =0;
    
if(this.Location .Y==0&&this.shubiao ==0 )
    
this.ClientSize = new System.Drawing.Size(196,2);
   }


   
private void Form1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
   
{if(this.Top <0this.Top =0;
  
   }

   
private void menuItem1_Click(object sender, System.EventArgs e)
   
{
    MessageBox.Show(
"     滨州职业学院-软件工程学院计算机信息科学系05级软件-水中游制作   xcligood@gmail.com","QQ界面程序");
   }


   
private void notifyIcon1_DoubleClick(object sender, System.EventArgs e)
   
{
    
if(this.WindowState== System.Windows.Forms.FormWindowState.Normal )
    
{this.WindowState = System.Windows.Forms.FormWindowState.Minimized;this.Opacity =0;}
else {this.WindowState = System.Windows.Forms.FormWindowState.Normal ;
     
this.Opacity =1;}


   }


   
private void pictureBox1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
   
{
             
this.notifyIcon1.Visible = false;
    Application.Exit();
   }


   
private void pictureBox1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
   
{
    
this.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
   }


   
private void pictureBox2_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
   
{
    
this.pictureBox2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
   }


   
private void pictureBox2_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
   
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
       
this.WindowState = FormWindowState.Minimized;
    
this.pictureBox2.BorderStyle = System.Windows.Forms.BorderStyle.None;
    
this.Opacity =0;
   }


   
private void pictureBox1_MouseLeave(object sender, System.EventArgs e)
   
{
   
this.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;
   }


   
private void menuItem2_Click(object sender, System.EventArgs e)
   
{
    
this.notifyIcon1.Visible = false;
    Application.Exit();
   }



}

}


 

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace QQ
{
/// <summary>
/// Form2 的摘要说明。
/// </summary>
public class Form2 : System.Windows.Forms.Form
{
   private System.Windows.Forms.PictureBox pictureBox1;
   private System.Windows.Forms.PictureBox pictureBox2;
   private System.Windows.Forms.PictureBox pictureBox3;
   private System.Windows.Forms.PictureBox pictureBox4;
   /// <summary>
   /// 必需的设计器变量。
   /// </summary>
   private System.ComponentModel.Container components = null;

   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 窗体设计器生成的代码
   /// <summary>
   /// 设计器支持所需的方法 - 不要使用代码编辑器修改
   /// 此方法的内容。
   /// </summary>
   private void InitializeComponent()
   {
    System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form2));
    this.pictureBox1 = new System.Windows.Forms.PictureBox();
    this.pictureBox2 = new System.Windows.Forms.PictureBox();
    this.pictureBox3 = new System.Windows.Forms.PictureBox();
    this.pictureBox4 = new System.Windows.Forms.PictureBox();
    this.SuspendLayout();
    //
    // pictureBox1
    //
    this.pictureBox1.BackColor = System.Drawing.Color.Transparent;
    this.pictureBox1.Cursor = System.Windows.Forms.Cursors.Hand;
    this.pictureBox1.Location = new System.Drawing.Point(304, 5);
    this.pictureBox1.Name = "pictureBox1";
    this.pictureBox1.Size = new System.Drawing.Size(21, 21);
    this.pictureBox1.TabIndex = 0;
    this.pictureBox1.TabStop = false;
    this.pictureBox1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseUp);
    this.pictureBox1.MouseLeave += new System.EventHandler(this.pictureBox1_MouseLeave);
    this.pictureBox1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseDown);
    //
    // pictureBox2
    //
    this.pictureBox2.BackColor = System.Drawing.Color.Transparent;
    this.pictureBox2.Cursor = System.Windows.Forms.Cursors.Hand;
    this.pictureBox2.Location = new System.Drawing.Point(258, 5);
    this.pictureBox2.Name = "pictureBox2";
    this.pictureBox2.Size = new System.Drawing.Size(21, 21);
    this.pictureBox2.TabIndex = 1;
    this.pictureBox2.TabStop = false;
    this.pictureBox2.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pictureBox2_MouseUp);
    this.pictureBox2.MouseLeave += new System.EventHandler(this.pictureBox1_MouseLeave);
    this.pictureBox2.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pictureBox2_MouseDown);
    //
    // pictureBox3
    //
    this.pictureBox3.BackColor = System.Drawing.Color.Transparent;
    this.pictureBox3.Cursor = System.Windows.Forms.Cursors.Hand;
    this.pictureBox3.Location = new System.Drawing.Point(156, 210);
    this.pictureBox3.Name = "pictureBox3";
    this.pictureBox3.Size = new System.Drawing.Size(76, 22);
    this.pictureBox3.TabIndex = 2;
    this.pictureBox3.TabStop = false;
    this.pictureBox3.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pictureBox3_MouseUp);
    this.pictureBox3.MouseLeave += new System.EventHandler(this.pictureBox3_MouseLeave);
    this.pictureBox3.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pictureBox3_MouseDown);
    //
    // pictureBox4
    //
    this.pictureBox4.BackColor = System.Drawing.Color.Transparent;
    this.pictureBox4.Cursor = System.Windows.Forms.Cursors.Hand;
    this.pictureBox4.Location = new System.Drawing.Point(240, 210);
    this.pictureBox4.Name = "pictureBox4";
    this.pictureBox4.Size = new System.Drawing.Size(76, 22);
    this.pictureBox4.TabIndex = 3;
    this.pictureBox4.TabStop = false;
    this.pictureBox4.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseUp);
    this.pictureBox4.MouseLeave += new System.EventHandler(this.pictureBox1_MouseLeave);
    this.pictureBox4.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pictureBox4_MouseDown);
    //
    // Form2
    //
    this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
    this.BackColor = System.Drawing.SystemColors.Control;
    this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
    this.ClientSize = new System.Drawing.Size(330, 245);
    this.Controls.Add(this.pictureBox4);
    this.Controls.Add(this.pictureBox3);
    this.Controls.Add(this.pictureBox2);
    this.Controls.Add(this.pictureBox1);
    this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
    this.Name = "Form2";
    this.ShowInTaskbar = false;
    this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
    this.Text = "QQ用户登录";
    this.TopMost = true;
    this.Click += new System.EventHandler(this.Form2_Click);
    this.ResumeLayout(false);

   }
   #endregion
      private void Form2_Click(object sender, System.EventArgs e)
   {
    MessageBox.Show("说明:/n   体验用C#制作类似QQ窗体停靠的效果!/n请直接按“登录”键进行登录!/n/n     滨州职业学院-软件工程学院/n计算机信息科学系05级软件-水中游制作/n /t/txcligood@gmail.com","QQ界面程序");
   }

   private void pictureBox3_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
   {
    this.pictureBox3.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
   }

   private void pictureBox3_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
   {
    Form1 str =new Form1();//建立一个实例对象名字为str,Form2为新窗体的名字。
    str.Show();
    this.Hide();
   }

   private void pictureBox3_MouseLeave(object sender, System.EventArgs e)
   {
    this.pictureBox3.BorderStyle = System.Windows.Forms.BorderStyle.None ;
   }

   private void pictureBox2_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
   {
    this.pictureBox2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
   }

   private void pictureBox2_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
   {this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
    this.pictureBox2.BorderStyle = System.Windows.Forms.BorderStyle.None ;
  
   }

   private void pictureBox1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
   {
    this.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
   }

   private void pictureBox1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
   {
    Application.Exit();
   }

   private void pictureBox1_MouseLeave(object sender, System.EventArgs e)
   {
    this.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.None ;
    this.pictureBox2.BorderStyle = System.Windows.Forms.BorderStyle.None ;
    this.pictureBox4.BorderStyle = System.Windows.Forms.BorderStyle.None ;
   }

   private void pictureBox4_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
   {
    this.pictureBox4.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
   }
}
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值