日期:2012-03-07  浏览次数:20427 次

其实是一个 无边框窗体,写成的表单类....但是外表看起来和普通的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( bo