首先将FormBorderStyle设置为None
然后在Form顶端添加你喜欢的最大化,最小化,以及关闭按钮
实现窗体的移动,代码如下:
bool formMove = false;//窗体是否移动
Point formPoint;//记录窗体的位置
private void Form1_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)//按下的是鼠标左键
{
formMove = false;//停止移动
}
}
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
formPoint = new Point();
int xOffset;
int yOffset;
if (e.Button == MouseButtons.Left)
{
xOffset = -e.X - SystemInformation.FrameBorderSize.Width;
yOffset = -e.Y - SystemInformation.FrameBorderSize.Height;//SystemInformation.CaptionHeight -
formPoint = new Point(xOffset, yOffset);
formMove = true;//开始移动
}
温馨提示:答案为网友推荐,仅供参考