///<summary>
///窗体边框重绘制
///</summary>
///<param name="sender"></param>
///<param name="e"></param>
privatevoid Form1_Paint(object sender,PaintEventArgs e)
{
///自定义绘制边框颜色
//e.Graphics.DrawRectangle(Pens.DarkOliveGreen,0, 0, this.Width - 1, this.Height - 1);
e.Graphics.DrawRectangle(Common.FromCustomStyle.CustomFormBorder(),0, 0,this.Width -1, this.Height - 1);
}
2.Panel移动可拖动窗体
privatevoid panel1_MouseDown(object sender,MouseEventArgs e)
{
Common.FromCustomStyle.MoveForm(this,this.panel1);
}
///<summary>
///拖动Panel窗体移动
///</summary>
///<param name="form1">窗口实例</param>
///<param name="panel1">要拖动的Panel</param>
publicstaticvoid MoveForm(Form form1,System.Windows.Forms.Panel panel1)
{
ReleaseCapture();
SendMessage(form1.Handle,WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);//*********************调用移动无窗体控件函数
}
//定义无边框窗体Form
[DllImport("user32.dll")]//*********************拖动无窗体的控件
publicstaticexternbool ReleaseCapture();
[DllImport("user32.dll")]
publicstaticexternbool SendMessage(IntPtr hwnd, int wMsg,int wParam, int lParam);
publicconstint WM_SYSCOMMAND =0x0112;
publicconstint SC_MOVE = 0xF010;
publicconstint HTCAPTION = 0x0002;