移动图标
来源:互联网 发布:ubuntu swap 主分区 编辑:程序博客网 时间:2024/05/11 04:13
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;
using System.Drawing.Drawing2D;
using System.Runtime.InteropServices;
namespace 移动图标
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Opacity = 0.5;
}
//#############拖动窗体#############
private bool isMouseDown = false;
private Point FormLocation; //form的location
private Point mouseOffset; //鼠标的按下位置
//#############################
private void Form1_Load(object sender, EventArgs e)
{
this.Top = 20;
this.Left = Screen.PrimaryScreen.Bounds.Width - 80;
this.Width = 60;
this.Height = 20;
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
//美化窗体
Graphics g = e.Graphics;
Color FColor = Color.Red;
Color TColor = Color.Yellow;
Brush b = new LinearGradientBrush(this.ClientRectangle, FColor, TColor, LinearGradientMode.ForwardDiagonal);
g.FillRectangle(b, this.ClientRectangle);
}
private void Form1_MouseDoubleClick(object sender, MouseEventArgs e)
{
Form2 zhuye = new Form2();
zhuye.Show();
}
private void Form1_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
this.contextMenuStrip1.Show(Control.MousePosition);
}
}
private void 主页面ToolStripMenuItem_Click(object sender, EventArgs e)
{
Form2 zhuye = new Form2();
zhuye.Show();
}
private void 关于ToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("介绍说明", "欢迎使用");
}
private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
isMouseDown = true;
FormLocation = this.Location;
mouseOffset = Control.MousePosition;
}
}
private void Form1_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 Form1_MouseUp(object sender, MouseEventArgs e)
{
isMouseDown = false;
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using System.Runtime.InteropServices;
namespace 移动图标
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Opacity = 0.5;
}
//#############拖动窗体#############
private bool isMouseDown = false;
private Point FormLocation; //form的location
private Point mouseOffset; //鼠标的按下位置
//#############################
private void Form1_Load(object sender, EventArgs e)
{
this.Top = 20;
this.Left = Screen.PrimaryScreen.Bounds.Width - 80;
this.Width = 60;
this.Height = 20;
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
//美化窗体
Graphics g = e.Graphics;
Color FColor = Color.Red;
Color TColor = Color.Yellow;
Brush b = new LinearGradientBrush(this.ClientRectangle, FColor, TColor, LinearGradientMode.ForwardDiagonal);
g.FillRectangle(b, this.ClientRectangle);
}
private void Form1_MouseDoubleClick(object sender, MouseEventArgs e)
{
Form2 zhuye = new Form2();
zhuye.Show();
}
private void Form1_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
this.contextMenuStrip1.Show(Control.MousePosition);
}
}
private void 主页面ToolStripMenuItem_Click(object sender, EventArgs e)
{
Form2 zhuye = new Form2();
zhuye.Show();
}
private void 关于ToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("介绍说明", "欢迎使用");
}
private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
isMouseDown = true;
FormLocation = this.Location;
mouseOffset = Control.MousePosition;
}
}
private void Form1_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 Form1_MouseUp(object sender, MouseEventArgs e)
{
isMouseDown = false;
}
}
}
0 0
- 移动图标
- GUI移动图标
- Android 响应键盘移动图标
- TTreeView移动节点和图标
- 触摸图标随着手指移动
- 任务栏程序图标与托盘图标的移动
- google地图 图标移动,地址搜索,双击图标返回地址
- 关于手势拖动图标移动图标(附带滑动效果)
- 去掉任务栏图标.不显示移动矩形
- 去除android2.1移动设备3G图标
- 电脑桌面上的图标移动不了!.
- Android箭头图标移动动画实现
- 鼠标移动到版块图标产生的渐变效果
- js - 图标在网页上漂浮移动效果
- Delphi 模拟鼠标在任务栏的图标上面逐个移动
- js - 图标在网页上漂浮移动效果
- JQuery_鼠标移动到图标上显示相应信息
- 快速生成移动设备应用图标的在线工具 - makeappicon
- 第三周项目(2)-1输出*图案
- 如何真正的学好java,能够成为企业炙手可热的java大神
- LoadRunner12.x简易入门教程--(一)回放与录制
- poj1128(拓扑排序)
- form表单填写,enter键实现tab键的下一个input获得焦点实现
- 移动图标
- 第三周项目二-本月有几天
- 今日BBC
- PPZ_SYSTICK
- 从背景差分到深度学习方法的目标检测与前背景分离
- 【LeetCode】20. Valid Parentheses
- Java序列化与JSON序列化大比拼
- js拖拽文件上传
- 第三周项目三输出星号图