using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Drawing.Imaging;
namespace CustomForm
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class CustomForm : System.Windows.Forms.Form
{
public CustomForm()
{
InitializeComponent();
}
Image backBitmap=null;
Form frm2=new Form();
bool isMove=true;
private const int WM_NCHITTEST = 0x84;
private const int HTCLIENT = 0x1;
private const int HTCAPTION = 0x2;
public override Image BackgroundImage
{
get
{
return backBitmap;
}
set
{
backBitmap=value;
SetBackground(this.backBitmap);
this.Width=value.Width;
this.Height=value.Height;
}
}
protected override void WndProc(ref Message m)
{
switch(m.Msg)
{
case WM_NCHITTEST:
base.WndProc(ref m);
if ((int)m.Result == HTCLIENT&&isMove)
m.Result = (IntPtr)HTCAPTION;
return;
break;
}
base.WndProc(ref m);
}
public bool IsMoveForm
{
get
{
return isMove;
}
set
{
isMove=value;
}
}