c#中如何实现无边框窗口的移动
3个回答
2013-12-11
展开全部
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;namespace WindowsFormsApplication1
{
public partial class noneForm : Form
{
public noneForm()
{
InitializeComponent();
}
private bool isMouseDown = false;
private Point FormLocation; //form的location
private Point mouseOffset; private void btnExit_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
isMouseDown = true;
FormLocation = this.Location;
mouseOffset = Control.MousePosition;
}
} private void noneForm_MouseUp(object sender, MouseEventArgs e)
{
isMouseDown = false;
} private void noneForm_MouseMove(object sender, MouseEventArgs e)
{
//鼠标的按下位置
int _x = 0;
int _y = 0;
if (isMouseDown)
{
Point pt = Control.MousePosition;
_x = mouseOffset.X - pt.X;
_y = mouseOffset.Y - pt.Y; this.Location = new Point(FormLocation.X - _x, FormLocation.Y - _y);
}
} private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
我是帅哥栋 这是我代码!!
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;namespace WindowsFormsApplication1
{
public partial class noneForm : Form
{
public noneForm()
{
InitializeComponent();
}
private bool isMouseDown = false;
private Point FormLocation; //form的location
private Point mouseOffset; private void btnExit_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
isMouseDown = true;
FormLocation = this.Location;
mouseOffset = Control.MousePosition;
}
} private void noneForm_MouseUp(object sender, MouseEventArgs e)
{
isMouseDown = false;
} private void noneForm_MouseMove(object sender, MouseEventArgs e)
{
//鼠标的按下位置
int _x = 0;
int _y = 0;
if (isMouseDown)
{
Point pt = Control.MousePosition;
_x = mouseOffset.X - pt.X;
_y = mouseOffset.Y - pt.Y; this.Location = new Point(FormLocation.X - _x, FormLocation.Y - _y);
}
} private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
我是帅哥栋 这是我代码!!
2013-12-11
展开全部
在桌面空白处 右键单击 属性 外观选项卡 效果
在 "拖动时显示窗口内容" 前打勾 然后确定!
在 "拖动时显示窗口内容" 前打勾 然后确定!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-12-11
展开全部
这个需要一定技巧。。按着鼠标左键不放。。拖动鼠标。。一直到屏幕边缘。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询