c# capture = true
来源:互联网 发布:淘宝店运动壹号怎么样 编辑:程序博客网 时间:2024/06/01 18:07
这东西邪门的很~ 开了之后无法相应 MouseDown 和 MouseUp了
msdn: 当控件已捕获鼠标时,它接收鼠标输入,不论光标是否在其边框内。 通常只有在执行拖动操作时才捕获鼠标。
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Drawing.Drawing2D;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;namespace WindowsFormsApplication1{ public partial class Form1 : Form { private Point DownPoint = Point.Empty; private Pen MyPen; private Rectangle srcRect; private bool f = false; public Form1() { InitializeComponent(); } private void pictureBox1_Paint(object sender, PaintEventArgs e) { if (srcRect != Rectangle.Empty) { MyPen = new Pen(Color.Black, 1); e.Graphics.DrawRectangle(MyPen, srcRect); } } private void pictureBox2_Paint(object sender, PaintEventArgs e) { if (srcRect != Rectangle.Empty) { e.Graphics.DrawImage(this.pictureBox1.Image, new Rectangle(0, 0, srcRect.Width, srcRect.Height), srcRect, GraphicsUnit.Pixel); } } private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { if (f) { int w = Math.Abs(e.X - DownPoint.X); int h = Math.Abs(e.Y - DownPoint.Y); if (e.X > DownPoint.X) srcRect = new Rectangle(DownPoint.X, DownPoint.Y, w, h); else srcRect = new Rectangle(e.X, e.Y, w, h); this.pictureBox1.Invalidate(); this.pictureBox1.Update(); this.pictureBox2.Invalidate(); this.pictureBox2.Update(); } } private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { this.Capture = true; //注释掉后一切正常 if (DownPoint == Point.Empty) { f = true; DownPoint.X = e.X; DownPoint.Y = e.Y; } } } private void pictureBox1_MouseUp(object sender, MouseEventArgs e) { if (DownPoint != Point.Empty) { DownPoint = Point.Empty; srcRect = Rectangle.Empty; this.pictureBox1.Invalidate(); this.pictureBox1.Update(); } MessageBox.Show("up"); f = false; } }}
0 0
- c# capture = true
- C#使用Capture摄像头
- asp.net C# AutoPostBack=“true”
- C# - Capture Full IE Document
- Capture
- Image Capture Whole Web Page using C#
- C# 摄像头视频捕捉 (使用DirectX.Capture)
- C#正则表达式:group和capture
- Spring abstract="true" merge="true"
- auto_now_add=True和auto_now_add=True
- 详细AutoEventWireup <@ Page language=c# AutoEventWireup="false"和“True”>的研究
- C# VS2010发布问题---<compilation debug="true" targetFramework="4.0">
- C# WinForm 给某动态控件设置 IsBalloon = true的ToolTip 即 气泡状提示
- c# winform在窗体topmost=true的情况下调用exe
- c#设置xml内容不换行;添加属性为xsi:nil="true"的空节点
- C#连接sqlserver时如何让Integrated Security=True生效
- elipse retarget="true"
- Trusted_Connect=true
- css透明度的一些兼容测试
- ArcGIS教程:地统计模拟的重要概念
- IO Manager and Device Driver
- C++如何监听http请求
- 关闭Mac OS X的Dashboard和Spotlight --
- c# capture = true
- iOS开发的一些奇巧淫技
- 单点登入登出
- Android通过包名启动Activity
- 导出Excel
- 运维工程师职业发展路线经验分享
- android 应用的基本组件介绍
- Ruby on Rails微信开发3——自定义菜单的创建
- jsp中的basePath