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

其实是一个 无边框窗体,写成的表单类....但是外表看起来和普通的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.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
    this.syslist.ImageSize = new System.Drawing.Size(21, 21);
    this.syslist.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("syslist.ImageStream")));
    this.syslist.TransparentColor = System.Drawing.Color.Transparent;
    // 
    // XpForm
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
    this.ClientSize = new System.Drawing.Size(280, 136);
    this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
    this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
     = "XpForm";
    this.Text = "APC心灵空间";  }
   #endregion  /// <summary>
   /// 应用程序的主入口点。
   /// </summary>
   [STAThread]
   static void Main() 
   {
    //XpForm xf=new XpForm();
    //xf.SysDoubleClick+=new SysHandler(xf.ni_DoubleClick);
    Application.Run(new XpForm());  }
//######################### 自 定 函 数 ##############################
   private void RePaint(bool ClearAll)
   {
    Graphics g=this.CreateGraphics();
    if(ClearAll==true){g.Clear(Color.FromArgb(242,242,242));}
    //画XP边框
    g.DrawImage(imglist.Images[1],0,0,this.Width+50,30);   //横幅
    g.DrawImage(imglist.Images[0],0,0,6,30);      //左角
    g.DrawImage(imglist.Images[2],this.Width-6,0,6,30);    //右角
    g.DrawImage(imglist.Images[5],0,this.Height-4,this.Width+50,4);//下边
    g.DrawImage(imglist.Images[3],0,7,4,this.Height);      //左边
    g.DrawImage(imglist.Images[4],this.Width-4,7,4,this.Height);//右边
    //画图标
    g.DrawImage((Image)this.Icon.ToBitmap(),new Rectangle(8,6,FormIconWidth,FormIconHeight));
    //画标题
    g.DrawString(this.Text,new Font("宋体",9,FontStyle.Bold),new SolidBrush(Color.White),32,10);
    //计算..画按钮
    InitSysCmd();
    int SysIndex=1;
    for(int i=0;i<=6;i++)
    {
     //if(SysVisible[i]==1)
     if(SysCmd[i,0]==1)
     {
      g.DrawImage(syslist.Images[i],this.Width-ONE*SysIndex-6,6,21,21);
      SysCmd[i,3]=this.Width-ONE*SysIndex-6;  //记录各SysCmd的Rect.X
      SysCmd[8,5]=this.Width-ONE*SysIndex-6; //标题栏拖拽的长度
      SysIndex+=1;
     }
    }   g.Dispose();
   }
   private void RePaint()
   {
    Bitmap b=new Bitmap(this.Width,this.Height);
    Graphics bmp=Graphics.FromImage((Image)b);
    
    //Bitmap c=new Bitmap(100,100,this.CreateGraphics());
    //g.Clear(this.BackColor);
    
    //画XP边框
    bmp.DrawImage(imglist.Images[1],0,0,this.Width+50,30);   //横幅
    bmp.DrawImage(imglist.Images[0],0,0,6,30);      //左角
    bmp.DrawImage(imglist.Images[2],this.Width-6,0,6,30);    //右角
    bmp.DrawImage(imglist.Images[5],0,this.Height-4,this.Width+50,4);//下边
    bmp.DrawImage(imglist.Images[3],0,7,4,this.Height);      //左边
    bmp.DrawImage(imglist.Images[4],this.Width-4,7,4,this.Height);//右边
    //画图标
    bmp.DrawImage((Image)this.Icon.ToBitmap(),new Rectangle(8,6,FormIconWidth,FormIconHeight));
    //画标题
    bmp.DrawString(this.Text,new Font("宋体",9,FontStyle.Bold),new SolidBrush(Color.White),32,10);
    //计算..画按钮
    InitSysCmd();
    int SysIndex=1;
    for(int i=0;i<=6;i++)
    {
     //if(SysVisible[i]==1)
     if(SysCmd[i,0]==1)
     {
      bmp.DrawImage(syslist.Images[i],this.Width-ONE*SysIndex-6,6,21,21);
      SysCmd[i,3]=this.Width-ONE*SysIndex-6;  //记录各SysCmd的Rect.X
      SysCmd[8,5]=this.Width-ONE*SysIndex-6; //标题栏拖拽的长度
      SysIndex+=1;
     }
    }
             Graphics g=this.CreateGraphics();
    g.DrawImage(b,0,0);
    bmp.Dispose();
    g.Dispose();
   }  private void ReCreateRegion()
   {
    Rectangle r=Screen.GetWorkingArea(this);
    Point[] p=new Point[]{
           new Point(0,6),
           new Point(1,4),
           new Point(4,1),
           new Point(6,0),
           new Point(this.Width-6,0),
           new Point(this.Width-4,1),
           new Point(this.Width-1,4),
           new Point(this.Width-1,5),
           new Point(this.Width,this.Height),
           new Point(0,this.Height)};
    byte[] b=new byte[]{
            (byte)PathPointType.Line,
            (byte)PathPointType.Line,
            (byte)PathPointType.Line,
            (byte)PathPointType.Line,
            (byte)PathPointType.Line,
            (byte)PathPointType.Line,
            (byte)PathPointType.Line,
            (byte)PathPointType.Line,
            (byte)PathPointType.Line,
            (byte)PathPointType.Line};
    System.Drawing.Drawing2D.GraphicsPath path=new GraphicsPath(p,b);
    this.Region=new Region(path);  }
   private void InitSysCmd()
   {
    if(Sys_Close_Visible==true){SysCmd[0,0]=1;}
    else{SysCmd[0,0]=0;}
    if(Sys_Max_Visible==true){SysCmd[1,0]=1;}
    else{SysCmd[1,0]=0;}
    if(Sys_Res_Visible==true){SysCmd[2,0]=1;}
    else{SysCmd[2,0]=0;}
    if(Sys_Min_Visible==true){SysCmd[3,0]=1;}
    else{SysCmd[3,0]=0;}
    if(Sys_Up_Visible==true){SysCmd[5,0]=1;}
    else{SysCmd[5,0]=0;}
    if(Sys_Down_Visible==true){SysCmd[4,0]=1;}
    else{SysCmd[4,0]=0;}
    if(Sys_Tray_Visible==true){SysCmd[6,0]=1;}
    else{SysCmd[6,0]=0;}
   }
   private void DoClick(int i)
   {
    switch(i)
    {
     case 0://关闭
      this.Close();
      break;
     case 1://最大化
      this.WindowState=FormWindowState.Maximized;
      break;
     case 2://还原
      this.WindowState=FormWindowState.Normal;
      break;
     case 3://最小化
      this.WindowState=FormWindowState.Minimized;
      break;
     case 4://放下
      =FormRect.Y;
      this.Left=FormRect.X;
      this.Width=FormRect.Width;
      this.Height=FormRect.Height;
      Sys_Down_Visible=false;
      Sys_Up_Visible=true;
      //this.RePaint();
      break;
     case 5://收起
      FormRect=new Rectangle(this.Left,,this.Width,this.Height);
      this.Height=30;
      =0;
      Sys_Up_Visible=false;
      Sys_Down_Visible=true;
      this.RePaint();
      break;
     case 6://缩入托盘
      ni.Text=TempTrayToolTip;
      ni.Icon=TrayIcon;
      ni.ContextMenu=TrayContextMenu;
      this.WindowState=FormWindowState.Minimized;
      this.ShowInTaskbar=false;
      this.Visible=false;
      ni.Visible=true;
      break;
    }   }
   private void ni_DoubleClick(object sender,System.EventArgs e)
   {
    OnSysDoubleClick(e);
    if(ShowInTray==true)
    {
     ni.Visible=true;
    }
   }
   void OnSysDoubleClick(System.EventArgs e)
   {
    if(this.Visible==true)
    {
     this.WindowState=FormWindowState.Minimized;
     this.ShowInTaskbar=false;
     this.Visible=false;
     ni.Visible=true;
    }
    else
    {
     int mStyle=WS_SYSMENU;
     if(Sys_Max_Visible==true){mStyle=mStyle|WS_MAXIMIZEBOX;}
     if(Sys_Min_Visible==true){mStyle=mStyle|WS_MINIMIZEBOX;}    if(ShowInTray==false){ni.Visible=false;}
    this.ShowInTaskbar=true;
     this.WindowState=FormWindowState.Minimized;
     int a=SetWindowLongA(this.Handle.ToInt32(),GWL_STYLE,mStyle);
     this.Visible=true; 
                 this.WindowState=FormWindowState.Normal;
    }
   }#region __重 载 事 件___
   //######################### 重 载 事 件 ###############################
   protected override void OnLoad(System.EventArgs e)
   {
    int mStyle=WS_SYSMENU;
    if(Sys_Max_Visible==true){mStyle=mStyle|WS_MAXIMIZEBOX;}
    if(Sys_Min_Visible==true){mStyle=mStyle|WS_MINIMIZEBOX;}
    int a=SetWindowLongA(this.Handle.ToInt32(),GWL_STYLE,mStyle);
    if(IsShowInTray==true){ni.Icon=TrayIcon;ni.ContextMenu=TrayContextMenu;ni.Text=TempTrayToolTip;ni.Visible=true;}
    .DoubleClick+=new System.EventHandler(_DoubleClick);
    this.SetStyle(ControlStyles.DoubleBuffer|ControlStyles.ResizeRedraw|ControlStyles.ContainerControl,true);
   }
   protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
   {
    //base.OnPaint(e);
    this.RePaint();
    base.OnPaint(e);
    //ee=e;
   }
   
   protected override void OnResize(System.EventArgs e)
   {
    Rectangle r=Screen.GetWorkingArea(this);
    this.MaximumSize=new Size(r.Width,r.Height);
    if(this.WindowState==FormWindowState.Maximized)
    {
     if(Sys_Max_Visible==true)
     {
      Sys_Max_Visible=false;
      Sys_Res_Visible=true;
     }
     if(Sys_Up_Visible==true)
     {
      Sys_Up_Visible=false;
      CanUp=1;
     }
    }
    if(this.WindowState==FormWindowState.Normal)
    {
     if(Sys_Res_Visible==true)
     {
      Sys_Max_Visible=true;
      Sys_Res_Visible=false;
     }
     if(CanUp==1)
     {
      Sys_Up_Visible=true;
      CanUp=0;
     }
    }
    this.RePaint();
    //this.OnPaint(ee);
    ReCreateRegion();
    this.Refresh();
   }
   protected override void OnMouseMove(System.Windows.Forms.MouseEventArgs e)
   {
    if(CanMove==true)
    {
     //this.Cursor=Cursors.SizeAll;
     //=Cursor.Position.Y-CurPoint.Y;
     //this.Left=Cursor.Position.X-CurPoint.X;
     if(CurPoint.X>SysCmd[8,3] && CurPoint.X<SysCmd[8,5] && CurPoint.Y<30 && (Sys_Res_Visible!=true ))
     {
      ReleaseCapture();
      SendMessage(this.Handle,WM_SYSCOMMAND,SC_MOVE+HTCAPTION, 0); 
     }
     
    }    Graphics g=this.CreateGraphics();
    for(int i=0;i<=6;i++)
    {
     if(SysCmd[i,0]==1)
     {
      if(e.X>SysCmd[i,3] && e.X<SysCmd[i,3]+21 && e.Y>6 && e.Y<27)
      {g.DrawImage(syslist.Images[SysCmd[i,2]],SysCmd[i,3],6,21,21);}
      else{g.DrawImage(syslist.Images[SysCmd[i,1]],SysCmd[i,3],6,21,21);}
     }
    }
    g.Dispose();   CurPoint2.X=Cursor.Position.X-this.Left;
    CurPoint2.Y=Cursor.Position.Y-;
   }
   protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
   {
    if(e.Button==MouseButtons.Left && e.X>SysCmd[8,3] && e.X<SysCmd[8,5] && e.Y<30)
    {
     CanMove=true;
    }
    CurPoint.X=e.X;
    CurPoint.Y=e.Y;
   }  protected override void OnMouseUp(System.Windows.Forms.MouseEventArgs e)
   {
    //if(e.Button==MouseButtons.Left && e.X>SysCmd[8,3] && e.X<SysCmd[8,5] && e.Y<30)
    //{
     CanMove=false;
     this.Cursor=Cursors.Default;
    //}
   }  protected override void OnClick(System.EventArgs e)
   {
    for(int i=0;i<=6;i++)
    {
     if(SysCmd[i,0]==1)
     {
      if(CurPoint.X>SysCmd[i,3] && CurPoint.X<SysCmd[i,3]+21 && CurPoint.Y>6 && CurPoint.Y<27)
      {DoClick(i);}
      else{}
     }
    }  
   }
   protected override void OnDoubleClick(System.EventArgs e)
   {
    if(CurPoint.X>SysCmd[8,3] && CurPoint.X<SysCmd[8,5] && CurPoint.Y<30 && (Sys_Max_Visible==true||Sys_Res_Visible==true ))
    {
     if(this.WindowState==FormWindowState.Maximized)
     {
      this.WindowState=FormWindowState.Normal;
     }
     else
     {
      this.WindowState=FormWindowState.Maximized;
     }
     this.Cursor=Cursors.Default;
    }
   }  protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
   {
    ni.Visible=false;
    ni.Dispose();
   }  protected override void OnTextChanged(System.EventArgs e)
   {this.RePaint(false);}  //protected override void OnLayout(System.Windows.Forms.LayoutEventArgs e)
   //{
    //mmd,在这里一加事件,居然从TRAY里恢复窗口的时候,不从画子控件了..郁闷
    //this.XpPanel.Location=new Point(4,30);
    //this.XpPanel.Size=new Size(this.Width-8,this.Height-34);
    //this.XpPanel.SendToBack();
    //foreach(Control c in this.Controls)
    //{
     //c.Parent=this.XpPanel;
    //}
   //}  //protected override void OnControlAdded(System.Windows.Forms.ControlEventArgs ce)
   //{
    /*  这也不是什么根本的办法,,,,,自己用还中....
    try
    {
     if(ce.Control.Parent==this && != && !=)
     {
      ce.Control.Parent=this.XpPanel;
     }
    }
    catch{}
    */
   //}  /*
   protected override void WndProc(ref Message m) 
   {
    base.WndProc(ref m);
    if (m.Msg == 0x0084 && CurPoint2.Y<=30 ) //WM_NCHITTEST
    {
     m.Result= (IntPtr)2; // HTCLIENT
     this.Text=this.CurPoint2.Y.ToString();
     return;
    }
    
   }*/
   //protected override void OnActivated(System.EventArgs e)
   //{  //}
   //####################################################################
   #endregion#region  自 定 义 属 性
   //####################### 自 定 义 属 性 #############################
   [
   Category("XpForm属性"),
   Description("获取或设置窗体的关闭按钮是否可见.")
   ]
   public bool Sys_Close_IsVisible
   {
    get{return Sys_Close_Visible;}
    set
    {
     Sys_Close_Visible=value;
     InitSysCmd();
     int SysIndex=0;
     for(int i=0;i<=6;i++)
     {
      if(SysCmd[i,0]==1)
      {
       SysIndex+=1;
      }
     }
     this.Invalidate(new Rectangle(this.Width-6-ONE*SysIndex,6,6+ONE*SysIndex,21));
    }
   }
   [
   Category("XpForm属性"),
   Description("获取或设置窗体的最大化按钮是否可见.")
   ]
   public bool Sys_Max_IsVisible
   {
    get{return Sys_Max_Visible;}
    set
    {
     Sys_Max_Visible=value;
     InitSysCmd();
     int SysIndex=0;
     for(int i=0;i<=6;i++)
     {
      if(SysCmd[i,0]==1)
      {
       SysIndex+=1;
      }
     }
     this.Invalidate(new Rectangle(this.Width-6-ONE*SysIndex,6,6+ONE*SysIndex,21));
    }
   }
   [
   Category("XpForm属性"),
   Description("获取或设置窗体的最小化按钮是否可见.")
   ]
   public bool Sys_Min_IsVisible
   {
    get{return Sys_Min_Visible;}
    set
    {
     Sys_Min_Visible=value;
     InitSysCmd();
     int SysIndex=0;
     for(int i=0;i<=6;i++)
     {
      if(SysCmd[i,0]==1)
      {
       SysIndex+=1;
      }
     }
     this.Invalidate(new Rectangle(this.Width-6-ONE*SysIndex,6,6+ONE*SysIndex,21));
    }
   }
   [
   Category("XpForm属性"),
   Description("获取或设置窗体的收起(向上)按钮是否可见.")
   ]
   public bool Sys_Up_IsVisible
   {
    get{return Sys_Up_Visible;}
    set
    {
     Sys_Up_Visible=value;
     InitSysCmd();
     int SysIndex=0;
     for(int i=0;i<=6;i++)
     {
      if(SysCmd[i,0]==1)
      {
       SysIndex+=1;
      }
     }
     this.Invalidate(new Rectangle(this.Width-6-ONE*SysIndex,6,6+ONE*SysIndex,21));
    }
   }
   [
   Category("XpForm属性"),
   Description("获取或设置窗体的缩入托盘按钮是否可见.")
   ]
   public bool Sys_Tray_IsVisible
   {
    get{return Sys_Tray_Visible;}
    set
    {
     Sys_Tray_Visible=value;
     InitSysCmd();
     int SysIndex=0;
     for(int i=0;i<=6;i++)
     {
      if(SysCmd[i,0]==1)
      {
       SysIndex+=1;
      }
     }
     this.Invalidate(new Rectangle(this.Width-6-ONE*SysIndex,6,6+ONE*SysIndex,21));
    }
   }
   [
   Category("XpForm属性"),
   Description("获取或设置窗体在托盘区显示的图标.")
   ]
   public Icon Sys_Icon
   {
    get{return TrayIcon;}
    set{TrayIcon=value;ni.Icon=TrayIcon;}
   }
   [
   Category("XpForm属性"),
   Description("获取或设置窗体在托盘区的上下文菜单.")
   ]
   public ContextMenu Sys_ContextMenu
   {
    get{return TrayContextMenu;}
    set{TrayContextMenu=value;ni.ContextMenu=TrayContextMenu;}
   }
   [
   Category("XpForm属性"),
   Description("获取或设置当鼠标停留在托盘区图标上时的提示文字.")
   ]
   public string Sys_ToolTip
   {
    get{return TempTrayToolTip;}
    set{TempTrayToolTip=value;TrayToolTip=TempTrayToolTip.Split("\n".ToCharArray(),0);ni.Text=value;}
   }
   [
   Category("XpForm属性"),
   Description("多行编辑控件中的文本行,作为字符串值的数组.(用于设置多行ToolTip)")
   ]
   public string[] Sys_ToolTip_Lines
   {
    get{return TrayToolTip;}
    set
    {
     string[] a=value;
     //TrayToolTip=value[0];
     TempTrayToolTip="";
     for(int i=0;i<=a.Length-1;i++)
     {
      TempTrayToolTip=TempTrayToolTip+a.GetValue(i).ToString();
      if(i<a.Length-1)
      {
       TempTrayToolTip=TempTrayToolTip+"\n";
      }
     }
     ni.Text=TempTrayToolTip;
     TrayToolTip=value;
    }
   }
   [
   Category("XpForm属性"),
   Description("获取或设置窗体刚启动时是否在托盘区显示.(需要先设置Sys_Icon属性.)")
   ]
   public bool ShowInTray
   {
    get{return IsShowInTray;}
    set
    {
     IsShowInTray=value;
     if(!this.DesignMode)
     {
      ni.Icon=TrayIcon;
      ni.ContextMenu=TrayContextMenu;
      ni.Text=TempTrayToolTip;
      ni.Visible=value;
     }
    }
   }
   [
   Category("XpForm属性"),
   Description("窗体图标的宽.)")
   ]
   public int FormIcon_Width
   {
    get{return FormIconWidth;}
    set
    {
     if(value>=FormIconWidth)
     {
      FormIconWidth=value;
      this.Invalidate(new Rectangle(8,6,value,FormIconHeight));
     }
     else
     {
      int temp=FormIconWidth;
      FormIconWidth=value;
      this.Invalidate(new Rectangle(8,6,value,temp));
     }
    }
   }
   [
   Category("XpForm属性"),
   Description("窗体图标的高.)")
   ]
   public int FormIcon_Height
   {
    get{return FormIconHeight;}
    set
    {
     if(value>=FormIconHeight)
     {
      FormIconHeight=value;
      this.Invalidate(new Rectangle(8,6,FormIconWidth,value));
     }
     else
     {
      int temp=FormIconHeight;
      FormIconHeight=value;
      this.Invalidate(new Rectangle(8,6,temp,value));
     }
    }
   }
   //####################################################################
   #endregion
 }
 }