using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;
...
..
.
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
[DllImport("user32.dll")]
public static extern bool ReleaseCapture();
[DllImport("user32.dll")]
public static extern bool SendMessage(IntPtr hwnd,int wMsg,int wParam,int lParam);
public const int WM_SYSCOMMAND=0x0112;
public const int SC_MOVE=0xF010;
public const int HTCAPTION=0x0002;
private void button2_Click(object sender, System.EventArgs e)
{//关闭应用程序
this.Close();
}
private void button1_Click(object sender, System.EventArgs e)
{//显示标题栏
if(this.button1.Text=="显示标题栏")
{
this.FormBorderStyle=FormBorderStyle.Fixed3D;
this.button1.Text="关闭标题栏";
}
else
{
this.FormBorderStyle=FormBorderStyle.None;
this.button1.Text="显示标题栏";
}
}
private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{//拖动窗体
ReleaseCapture();
SendMessage(this.Handle,WM_SYSCOMMAND,SC_MOVE+HTCAPTION, 0);
}
}