模仿QQ截图片

两个picturebox,一个放图片完整代码如下using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Xml;
namespace Test
{public partial class Form1 : Form{private bool MouseIsDown = false;private int _x, _y;private Rectangle MouseRect = Rectangle.Empty;public Form1(){InitializeComponent();}private void ResizeToRectangle(Point p){DrawRectangle();MouseRect.Width = p.X - MouseRect.Left;MouseRect.Height = p.Y - MouseRect.Top;DrawRectangle();}private void DrawRectangle(){Rectangle rect = this.RectangleToScreen(MouseRect);ControlPaint.DrawReversibleFrame(rect, Color.White, FrameStyle.Dashed);}private void DrawStart(Point StartPoint){barkPictureBox.Capture = true;Cursor.Clip = this.RectangleToScreen(new Rectangle(0, 0, ClientSize.Width, ClientSize.Height));MouseRect = new Rectangle(StartPoint.X, StartPoint.Y, 0, 0);}private void button1_Click(object sender, EventArgs e){}void barkPictureBox_MouseUp(object sender, MouseEventArgs e){barkPictureBox.Capture = false;Cursor.Clip = Rectangle.Empty;MouseIsDown = false;DrawRectangle();if (MouseRect.X == 0 || MouseRect.Y == 0 || MouseRect.Width == 0 || MouseRect.Height == 0)  //如果区域有一个是0就返回
            {}else{///代码
            }MouseRect = Rectangle.Empty;int sx = _x < e.X ? _x : e.X;int sy = _y < e.Y ? _y : e.Y;int w = Math.Abs(_x - e.X);int h = Math.Abs(_y - e.Y);Graphics g = Graphics.FromHwnd(pictureBox2.Handle);g.Clear(pictureBox2.BackColor);g.DrawImage(barkPictureBox.Image, new Rectangle(0, 0, w, h), sx, sy, w, h, GraphicsUnit.Pixel); }void barkPictureBox_MouseMove(object sender, MouseEventArgs e){if (MouseIsDown) ResizeToRectangle(new Point(e.X + barkPictureBox.Location.X, e.Y + barkPictureBox.Location.Y));}void barkPictureBox_MouseDown(object sender, MouseEventArgs e){_x = e.X;_y = e.Y;MouseIsDown = true;DrawStart(new Point(e.X + barkPictureBox.Location.X, e.Y + barkPictureBox.Location.Y));}private void Form1_Load(object sender, EventArgs e){barkPictureBox.MouseDown += new MouseEventHandler(barkPictureBox_MouseDown);barkPictureBox.MouseMove += new MouseEventHandler(barkPictureBox_MouseMove);barkPictureBox.MouseUp += new MouseEventHandler(barkPictureBox_MouseUp);}}
}

 

转载于:https://www.cnblogs.com/gc2013/p/3696743.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/258692.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

/usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.15' not found错误的解决

转载自&#xff1a;http://www.cnblogs.com/weinyzhou/p/4983306.html 升级cmake时&#xff0c;提示“Error when bootstrapping CMake:Problem while running initial CMake”&#xff0c;第二次运行./bootstrap时&#xff0c;直接的给出了错误原因&#xff1a; [rootloc…

Spring中Bean的定义继承

以下内容引用自http://wiki.jikexueyuan.com/project/spring/bean-definition-inheritance.html&#xff1a; Bean定义继承 bean定义可以包含很多的配置信息&#xff0c;包括构造函数的参数&#xff0c;属性值&#xff0c;容器的具体信息例如初始化方法&#xff0c;静态工厂方法…

python实时连接oracle_Python连接Oracle

Python连接Oracle当前环境&#xff1a;Linux Centos 71. 下载安装包cx_Oracle由于我本地Python版本是2.7,所以选择是2.7版本wget https://pypi.python.org/packages/e1/18/00987c6a9af9568ee87d1fcba877407684a3f1b87515e5eb82d5d5acb9ff/cx_Oracle-6.0rc1-py27-1.x86_64.rpm#m…

C语言字符串函数大全

转载自http://www.360doc.com/content/08/0723/22/26860_1462024.shtml# C语言字符串函数大全 函数名: stpcpy 功能: 拷贝一个字符串到另一个 用法: char *stpcpy(char *destin, char *source); 程序例: #include<stdio.h> #include<string.h> int main(void) { ch…

Makefile中 -I -L -l区别

转载自&#xff1a;http://blog.csdn.net/davion_zhang/article/details/41805641 我们用gcc编译程序时&#xff0c;可能会用到“-I”&#xff08;大写i&#xff09;&#xff0c;“-L”&#xff08;大写l&#xff09;&#xff0c;“-l”&#xff08;小写l&#xff09;等参数&am…

PLT redirection through shared object injection into a running process

PLT redirection through shared object injection into a running process

python电脑版软件下载_Python for windows

Python是一门跨平台的脚本语言,Python规定了一个Python语法规则,实现了Python语法的解释程序就成为了Python的解释器,我们用的比较多的是C版本的Python,也就是使用C语言实现的Python解释器,除此之外还有使用Java实现的Jython和使用.NET实现的IronPython,这些实现可以使Python用…

Struts优缺点

跟Tomcat、Turbine等诸多Apache项目一样&#xff0c;是开源软件&#xff0c;这是它的一大优点。使开发者能更深入的了解其内部实现机制。 Struts开放源码框架的创建是为了使开发者在构建基于Java Servlet和JavaServer Pages&#xff08;JSP&#xff09;技术的Web应用时更加容易…

由Google Protocol Buffer的小例子引起的g++编译问题

问题 学习 Google Protocol Buffer 的使用和原理时&#xff0c;提供了一个小例子&#xff0c;讲述了protobuf的使用方法。 假如已经有了如下文件&#xff1a; 其中writer.cpp如下&#xff1a;#include "lm.helloworld.pb.h" #include<iostream> #include<…

用python编写表达式求值_用Python3实现表达式求值

Problem Description yizhen has no girlfriend due to his stupid brain that he even can’t solve a simple arithmetic roblem. Can you help him If you solve it and tell him the result, then he can find his lovers! So beautiful! Input The input一、题目描述请用 …

the first day

开博第一天&#xff0c;从此记录我生活学习的点滴&#xff0c;加油转载于:https://www.cnblogs.com/fkissx/p/3702132.html

驱动-问题解决

今天在网上买了一个二手的电脑&#xff0c;拿回来以后&#xff0c;发现有点问题&#xff0c;一个问题就是 1.usb插上U盘以后没有反应 解决方法&#xff1a; 尝试一、直接在网上下载了一个360驱动大师&#xff0c;更新了一下驱动&#xff0c;没有解决 尝试二、在网上下载了一个驱…

Swift 学习- 02 -- 基础部分2

class NamedShape{ var numberOfSides: Int 0 var name: String init(name: String) { self.name name } func simpleDecription() -> String { return "A shape with \(numberOfSides) \(name) sides" } } // 除了储存简单的属性之外,属性可以有 getter 和 set…

R-CNN detection 运行问题及办法

运行caffe官方提供的jupyter 的rcnn detection&#xff0c;总是出现各种问题。先将问题及方法汇集在此&#xff1a; 1. Selective Search 的安装问题 按照官网&#xff0c;我下载了selective_search_ijcv_with_python&#xff0c;但是在我的linux matlab2017a上总是出现问题&…

python怎么用lambda和map函数_Python之lambda匿名函数及map和filter的用法

现有两个元组((a),(b)),((c),(d))&#xff0c;请使用python中匿名函数生成列表[{a:c},{b:d}]t1 ((a), (c))t2 ((b), (d))print(list(map(lambda t: {t[0]: t[1]}, zip(t1, t2))))l lambda t1, t2: [{i: j} for i, j in zip(t1, t2)]print(l(t1, t2))map内置函数使用&#xf…

UVALive 5903 Piece it together(二分图匹配)

给你一个n*m的矩阵&#xff0c;每个点为B或W或.。然后你有一种碎片。碎片可以旋转&#xff0c;问可否用这种碎片精确覆盖矩阵。N,M<500 WB 《碎片 W 题目一看&#xff0c;感觉是精确覆盖&#xff08;最近被覆盖洗脑了&#xff09;&#xff0c;但是仔细分析可以知道&#xf…

将undefault和null的数据转换成bool类型的数据 使用!!

<script> var o{}; var anull; console.info(!!o.name); </script> 输出false 此方法是将undefault和null的数据转换成bool类型的数据. var model avalon.define({ $id: model, defaultvalue {},});<span ms-if"!!defaultvalue .cost" >测试</…

springcloud(五):熔断监控Hystrix Dashboard和Turbine

Hystrix-dashboard是一款针对Hystrix进行实时监控的工具&#xff0c;通过Hystrix Dashboard我们可以在直观地看到各Hystrix Command的请求响应时间, 请求成功率等数据。但是只使用Hystrix Dashboard的话, 你只能看到单个应用内的服务信息, 这明显不够. 我们需要一个工具能让我们…

如何修改PKG_CONFIG_PATH环境变量

两种情况&#xff0c;如果你只是想加上某库的pkg&#xff0c;则选择下面其一&#xff1a;export PKG_CONFIG_PATH/usr/lib/pkgconfig/ 或者 export PKG_CONFIG_LIBDIR/usr/lib/pkgconfig/ 如果你想覆盖掉原来的pkg,选择后者。因为&#xff1a;PKG_CONFIG_LIBDIR的优先级比 PKG_…

python跨包导入包_python引入跨模块包

人生苦短&#xff0c;我学python。最近学习python&#xff0c;由于包的模块分的比较多。所以要用到跨模块引入 且调用中间的方法整体目录结构如下。需求&#xff1a;在 API模块 user.py 中 调用 plugin 模块中 douyin_login 下的方法。贴一下最终解决方案&#xff1a;from plug…