一个Xp风格的表单类(一)

其实是一个 无边框窗体,写成的表单类....但是外表看起来和普通的FORM完全一样.

呵呵. 最可惜的是,现在还没找到,在工具栏上放菜单的办法......哭....

下面是运行时候的图片..

我喜欢程序,更喜欢程序有个PL的界面....

但是网上似乎找不到详细的,关于此方面的教程或源码.

重绘时改用了双缓冲,在窗体上有动画的时候,重绘不会出现闪烁的现象了.

献丑一下,把源码贴出来,大家一起交流....

下面是引用,以及,声明的部分##########################################

using System;
using System.ComponentModel;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.IO;
using System.Runtime.InteropServices; 
namespace XpFormOfApc
{
 /// <summary>
 /// Form1 的摘要说明。
 /// </summary>
 
 public class XpForm : System.Windows.Forms.Form
 {
  public delegate void SysHandler(object sender,System.EventArgs e);
  public event SysHandler SysDoubleClick;

        //############API设置窗口STYLE#############
  private const int GWL_STYLE = (-16); 
  private const int WS_SYSMENU = 0x80000; 
  private const int WS_SIZEBOX = 0x40000; 
  private const int WS_MAXIMIZEBOX = 0x10000;
  private const int WS_MINIMIZEBOX=0x20000;
  [System.Runtime.InteropServices.DllImport("user32", EntryPoint="SetWindowLong")]
  private static extern int SetWindowLongA(int hwnd, int nIndex, int dwNewLong);
  //###########普通组件定义#################
  private System.ComponentModel.IContainer components;
  private System.Windows.Forms.ImageList imglist;
  private System.Windows.Forms.ImageList syslist;
  //###############组件属性##################
  //---系统按钮---
  private bool Sys_Close_Visible=true;
  private bool Sys_Max_Visible=true;
  private bool Sys_Res_Visible=false;
  private bool Sys_Min_Visible=true;
  private bool Sys_Down_Visible=false;
  private bool Sys_Up_Visible=true;
  private bool Sys_Tray_Visible=true;
  private bool IsShowInTray=false;
  private int FormIconWidth=16;
  private int FormIconHeight=16;
  private const int ONE=23;  //按钮宽21+2间隔
  private int[,] SysCmd=new int[9,7]{
                                            {1,0,7,0,6,21,21},
           {1,1,8,0,6,21,21},
           {0,2,9,0,6,21,21},
           {1,3,10,0,6,21,21},
           {0,4,11,0,6,21,21},
           {1,5,12,0,6,21,21},
           {1,6,13,0,6,21,21},
           {10,5,12,0,0,21,21},
           {11,5,12,32,0,0,30}
            }; //10-FORM_ICON   11-FORM_TITLE
  //---表单图标--托盘图标---
        private NotifyIcon ni=new NotifyIcon(); 
  private Icon TrayIcon;
  private ContextMenu TrayContextMenu;
  private string[] TrayToolTip;
  private string TempTrayToolTip;
  //public event SysOnDoubleClick (System.EventArgs e);    //托盘图标双击事件

  private Rectangle FormRect;//表单上一状态的RECT 用于Down还原

  //允许拖拽标志 - 坐标
  private bool CanMove=false;
  private Point CurPoint=new Point(0,0);
  private Point CurPoint2=new Point(0,0);


  //
  private int CanUp=0;

  //====================================================
  [DllImport("user32.dll")]
  public static extern bool ReleaseCapture();
  [DllImport("user32.dll")]
  public static extern bool SendMessage(IntPtr hwnd,int wMsg,int wParam,int lParam);
                                       
  private const int WM_SYSCOMMAND=0x0112;
  private const int SC_MOVE=0xF010;
  private const int HTCAPTION=0x0002;
  private const int HTRIGHT=0x0011;

################  下面是代码  ###############

public XpForm()
  {
   //
   // Windows 窗体设计器支持所必需的
   //
   InitializeComponent();
   //this.SetBounds(4,30,this.Width-8,this.Height-34);
   //
   // TOD 在 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()
  {
   this.components = new System.ComponentModel.Container();
   System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(XpForm));
   this.imglist = new System.Windows.Forms.ImageList(this.components);
   this.syslist = new System.Windows.Forms.ImageList(this.components);
   // 
   // imglist
   // 
   this.imglist.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
   this.imglist.ImageSize = new System.Drawing.Size(50, 50);
   this.imglist.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imglist.ImageStream")));
   this.imglist.TransparentColor = System.Drawing.Color.Black;
   // 
   // syslist
   // 
   this.syslist.C

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值