C#无标题栏也要实现窗体拖动
来源:互联网 发布:php下载网源码 编辑:程序博客网 时间:2024/06/08 16:12
public partial class Form1 : Form
{
// 窗体的屏幕坐标
Point formPoint;
// 鼠标光标的屏幕坐标
Point mousePoint;
public Form1()
{
InitializeComponent();
}
//退出程序
private void btnExit_Click(object sender, EventArgs e)
{
Application.Exit();
}
//恢复标题栏
private void btn_RecoverCaption_Click(object sender, EventArgs e)
{
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
}
//去掉标题栏
private void btn_NoCaption_Click(object sender, EventArgs e)
{
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
}
//窗体按下时...
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
// 获取窗体的屏幕坐标(x,y)
formPoint = this.Location;
// 获取鼠标光标的位置(屏幕坐标)
mousePoint = Control.MousePosition;
}
//鼠标在窗体移动时...
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
//获取鼠标移动时的屏幕坐标
Point mousePos = Control.MousePosition;
//改变窗体位置
this.Location = new Point(formPoint.X+mousePos.X - mousePoint.X,
formPoint.Y+mousePos.Y - mousePoint.Y);
}
}
}
{
// 窗体的屏幕坐标
Point formPoint;
// 鼠标光标的屏幕坐标
Point mousePoint;
public Form1()
{
InitializeComponent();
}
//退出程序
private void btnExit_Click(object sender, EventArgs e)
{
Application.Exit();
}
//恢复标题栏
private void btn_RecoverCaption_Click(object sender, EventArgs e)
{
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
}
//去掉标题栏
private void btn_NoCaption_Click(object sender, EventArgs e)
{
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
}
//窗体按下时...
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
// 获取窗体的屏幕坐标(x,y)
formPoint = this.Location;
// 获取鼠标光标的位置(屏幕坐标)
mousePoint = Control.MousePosition;
}
//鼠标在窗体移动时...
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
//获取鼠标移动时的屏幕坐标
Point mousePos = Control.MousePosition;
//改变窗体位置
this.Location = new Point(formPoint.X+mousePos.X - mousePoint.X,
formPoint.Y+mousePos.Y - mousePoint.Y);
}
}
}
0 0
- C#无标题栏也要实现窗体拖动
- C#实现无标题栏窗体的拖动
- C#拖动无标题栏窗体
- C#拖动无标题栏窗体
- C#窗体无标题栏拖动
- C#中怎么实现窗体无标题栏拖动
- C#无标题栏窗体鼠标拖动
- WPF:实现无标题栏窗体的拖动
- 拖动无标题栏窗体
- 无标题栏窗体拖动
- C# 实现无标题栏窗口拖动效果
- 如何拖动无标题栏窗体
- Winform无标题栏拖动窗体
- 拖动无标题栏窗体 整理
- c# 实现无标题栏的窗体移动
- 实现无标题栏拖动
- vb.net实现无标题栏窗体可拖动
- C# 实现拖动无边框窗体
- Linux_c 编程——判断编译器是大端还是小端
- Could not find gem 'sqlite3 (>= 0)' in any of the gem sources listed in you r Gemfile
- php——学习笔记,圆周率的三种书写方法看float用法
- rails 3遇到 Could not find a JavaScript runtime execjs错误(ubuntu)
- leetcode4-Add Two Num
- C#无标题栏也要实现窗体拖动
- gcc -D选项的作用
- ubuntu下jboss-seam-2.2.2.Final/examples/build.xml:754: warning: 'includeantruntime' was not set
- ExpandableButtonMenu |底部弹出菜单
- Firefox OS Quick Start(Firefox OS快速开始)
- 黑马程序员 学习日记(八)
- oracle中分析函数 (over rank dense_rank row_number)
- FoxCharts VFP开源项目 酷炫Chart
- mysql 命令